Skip to content
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

ZServer not threading #665

Closed
gogobd opened this issue Jul 1, 2019 · 13 comments · Fixed by zopefoundation/ZServer#17
Closed

ZServer not threading #665

gogobd opened this issue Jul 1, 2019 · 13 comments · Fixed by zopefoundation/ZServer#17

Comments

@gogobd
Copy link
Contributor

gogobd commented Jul 1, 2019

We're running ZServer 4.0.1 (that comes with Plone 5.2RC5) under Python 2.7. and I realized that I can't open urls with my browser whenever I'm in a breakpoint. Our zope.conf has "zserver-threads 6" but I'm getting the impression that ZServer doesn't thread. pstree shows one instance of the server, not more. We're using macOS High Sierra.

@gogobd
Copy link
Contributor Author

gogobd commented Jul 16, 2019

This behavior has been consistent for two weeks now.

@d-maurer
Copy link
Contributor

d-maurer commented Jul 18, 2019 via email

d-maurer added a commit to zopefoundation/ZServer that referenced this issue Jul 18, 2019
@d-maurer
Copy link
Contributor

This turned out to be a ZServer(not a Zope) bug.

Fixed by zopefoundation/ZServer#17

@gogobd
Copy link
Contributor Author

gogobd commented Jul 19, 2019

THANK YOU!

@gogobd
Copy link
Contributor Author

gogobd commented Jul 19, 2019

Unfortunately the problem's still there, I updated to master, confirmed the fix is active but the behavior of the server is still the same: no requests are being handled while I'm in a breakpoint, no threads are visible in pstree.

@gogobd gogobd reopened this Jul 19, 2019
@d-maurer
Copy link
Contributor

d-maurer commented Jul 19, 2019 via email

@gogobd
Copy link
Contributor Author

gogobd commented Jul 19, 2019

My zope.conf shows 'zserver-threads 6', my Control_Panel/Database/main/manage_main i see only one <Connection at .........> listed uner "Total number of objects in each cache". I'm starting with "./bin/instance" if that makes any difference.

@d-maurer
Copy link
Contributor

d-maurer commented Jul 19, 2019 via email

@gogobd
Copy link
Contributor Author

gogobd commented Jul 22, 2019

Thank you so much for your help, it's very appreciated!

So, I tried out the suggested breakpoint and: in ZRendevous.init i can see the RIGHT number of threads being passed in, and I can see that the while loop actually calls "thread.start_new_thread" 6 times in my case!

However when I create two Python Scripts, one that returns "Hi" and another that goes into an infinite while loop I can reproduce that the server is blocking. This is happening both with "instance fg" and "instance start".

I was now investigating a little further and things got a bit weird. in ZServerPublisher's init 5 out of 6 threads can not do "from ZPublisher.Publish import publish_module" - only the first one doesn't fail with an ImportError. That's the reason why I only have one thread. The funny thing is when I add a conditional breakpoint on that ImportError and execute the failing import statement in the debugger it works and I get no error. So there must be some sort of runtime concurrency / sequence problem which led me to a funny fix:

        import time
        import random
        time.sleep(random.random())
        from ZPublisher.Publish import publish_module

solves my problem and I can see all 6 configured threads in "/Control_Panel/Database/main". It's still completely misterious for me why this happens at all.

@d-maurer
Copy link
Contributor

d-maurer commented Jul 22, 2019 via email

@gogobd
Copy link
Contributor Author

gogobd commented Jul 22, 2019

My colleague iHam just suggested to use

from ZServer.ZPublisher.Publish import publish_module

instead of

from ZPublisher.Publish import publish_module

and: That seems to resolve all problems, including the deprication warning!

@icemac
Copy link
Member

icemac commented Aug 2, 2019

@gogobd So your problem is solved? Can this issue be closed then or should we keep it open until the connected issues are resolved and released?

@dataflake
Copy link
Member

This is long fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants