-
Notifications
You must be signed in to change notification settings - Fork 39
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
PIconnect no longer automatically disconnects from the server #487
Comments
The current solution was chosen based on this post: https://pisquare.osisoft.com/thread/12398#comment-61955 |
I guess I have a bug related to this issue. From time to time I get this System.InvalidOperationException when I access the database in a loop. And the system does not recover from it. How to fix it?
|
If you do the loop within the database = PI.PIAFDatabase(server="XXX", database="Production")
while(True):
try:
element = database.descendant(path_to_element)
break
except:
'''
System.InvalidOperationException:
Database 'Production' has been disconnected.
This is caused by using an object from a database
after calling PISystem.Disconnect.
'''
time.sleep(60.0)
continue
#
# do other stuff The SDK should handle connecting and disconnecting automatically. |
Bug report
Description
With commit fe138d9 the automatic disconnect from the server at exiting the context manager was disabled. This means connections to the database remain open until the python session ends, or the SDK's grace. This issue serves as a request for comments on how to fix this more efficiently.
To Reproduce
Running this snippet:
prints:
Expected behavior
The expected result would be
Possible solutions
The problem is that
PIconnect.PIAF.PIAFDatabase.__exit__
no longer callsself.server.Disconnect
. This was done intentionally to fix unexpected disconnects, but the current fix might not be the most efficient solution.System
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: