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
is there any right way to interrupt a started server? #68
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I need to find time to dig into it. |
I haven't experienced this issue, but the analysis seems sound. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@polymorphm Would you consider putting together a pull request implementing the approach you've outlined? |
I would be glad to make a pull request (in some days. at this weakend!). but I'm afraid that the names of new-functions may turn out to be not very good :-) . |
I've made pull #98 .. it seems, I've to do pull's "Checklist" :-) .. |
I'm submitting a ...
[x] bug report
[ ] feature request
[ ] question about the decisions made in the repository
Do you want to request a feature or report a bug?
bug? or may be it is a feature request?... no.. I think it is a bug (I don't know)
the method
server.interrupt
[of classcherrot.Server
] seems like useless.I can not invoke the method
server._set_interrupt()
[the propertyserver.interrupt
] from the same thread where I just invokedserver.start()
, because the methodserver.start()
is blocking the thread.and I can not invoke
server.interrupt()
in another thread, becauseserver._set_interrupt()
invokesserver.stop()
inside himself. butserver.stop()
isn't threadsafe!the method
server.stop()
isn't threadsafe -- because it has a race condition with the methodserver.start()
. and there isn't a way how to wait for the moment when the methodserver.start()
will pass his initialization (dangerous) point.how can I use right way to interrupt a server?
I've found the way (the workaround?) like this:
i.e I've tried to avoid using
server._set_interrupt()
, so I've got ability to invoke the methodserver.stop()
inside thethread A
after invoking the methodserver.start()
in the same thread (the race condition wouldn't happen).if the method
server.start()
anserver.stop()
would be use synchronization primitives -- it would NOT fix the problem(!) . because in this case the race contition withserver.stop()
will still happen at moment before starting the methodserver.start()
(in detail: inthread B
we can at random invokestop()
before invokingstart()
, so thestop()
will not stop anything).and of course -- I can not set
server.ready = False
in thethread B
, because I still have race condition for this variable with the methodserver.start()
invoked in thethread A
. it is the real problem..I think one of the way -- it is to split the method
server.start()
to two separated methods:this separation will allow to know that you can correctly invoke the method
server.stop()
-- after the start-initialization phase is done.thank you in advance!
The text was updated successfully, but these errors were encountered: