-
-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(config): allow concurrent access to pyrevit_config.ini #2516
fix(config): allow concurrent access to pyrevit_config.ini #2516
Conversation
I will try it with the installers tomorrow morning |
📦 New work-in-progress (wip) builds are available for 5.0.0.25013+1857-wip |
Me and my friend ChatG got this working using an ugly retry mechanism: using System.IO;
//...
// save config file to standard location
public void SaveConfigFile()
{
if (_adminMode)
{
logger.Debug("Config is in admin mode. Skipping save");
return;
}
logger.Debug("Saving config file \"{0}\"", PyRevitConsts.ConfigFilePath);
int retryCount = 5; // Number of retry attempts
int delayMilliseconds = 100; // Delay between retries
while (retryCount > 0)
{
try
{
_config.Save(PyRevitConsts.ConfigFilePath);
return; // Exit method if successful
}
catch (IOException ex) // Catch only IO exceptions related to file locking
{
retryCount--;
if (retryCount == 0)
{
throw new PyRevitException(string.Format("Failed to save config to \"{0}\" after multiple attempts. | {1}",
PyRevitConsts.ConfigFilePath, ex.Message));
}
logger.Debug("Retrying to save config file \"{0}\"... Remaining retries: {1}",
PyRevitConsts.ConfigFilePath, retryCount);
System.Threading.Thread.Sleep(delayMilliseconds); // Wait before retrying
}
catch (Exception ex)
{
throw new PyRevitException(string.Format("Failed to save config to \"{0}\". | {1}",
PyRevitConsts.ConfigFilePath, ex.Message));
}
}
} Thoughts @sanzoghenzo, except that it is a crappy way of doing it ;p |
Why does the "get current attachments" need to save the file? This clones and attachments thing starts to driving me mad 🤯 From a quick look at it, I believe this is the culprit:
We need to write back only if the list of attachments have changed. But in any case yes, we need to add some checks in the save method to handle this kind of concurrency. |
Trust me, plenty of BIM Managers do when they review files in Revit!
Want to do it @sanzoghenzo ? |
I'll try it, not sure if I can do this today; For the retry solution you proposed, this mitigates the problem but doesn't solve the root issue: what to do when multiple instances try to write on the same file? It's the whole git/cloud storage problem again and again... |
Agree 💯 |
📦 New work-in-progress (wip) builds are available for 5.0.0.25015+1341-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25015+1357-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25024+1520-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25024+1957-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25025+1310-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25030+1056-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25030+1130-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25030+1138-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25031+1700-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25032+1615-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25032+1635-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25032+1841-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25033+1337-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25033+1402-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25034+1241-wip |
📦 New work-in-progress (wip) builds are available for 5.0.0.25034+1511-wip |
📦 New public release are available for 5.0.0.24174+2300 |
fixes #2463 #2512
It seems to work on my machine, I ran 3 instances of revit 2023 one after another, and then 2 instances of revit 2025.