You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
micramm edited this page Nov 27, 2012
·
1 revision
Optional Methods
initServer
stopServer
The stopServer method is meant for cleanup actions that have to be called when the server is required to stop. This method is executed, for example, when the node server stops running the given server, or whenever the server exits with an error such as the identification error. #needlink.
Since it's not known ahead of time when stopServer may get called, it's important account for any possible state of the server. Suppose some big object is created in initServer and requires to be cleaned up upon exiting:
def initServer():
self.my_object = big_object()
One should not simply use self.my_object.cleanup() in stopServer because stopServer may get called even before initServer is executed. This would happen with the identification error #needlink. Instead use:
def stopServer():
if hasattr(self, 'my_object'):
self.my_object.cleanup()