Re: [gevent] gevent + multiprocessing = freeze

529 views
Skip to first unread message

Ian Epperson

unread,
Aug 24, 2012, 9:32:27 PM8/24/12
to gev...@googlegroups.com
I'm fairly sure you have to monkey patch after you finish all your imports.  Try moving "from multiprocessing import Pool" to the top.

Ian Epperson

On Fri, Aug 24, 2012 at 3:55 PM, Oleg Korsak <kamikaze.is...@gmail.com> wrote:
Hello, everybody!
I have a problem while runnung this simple code:

https://gist.github.com/3456736

It just freezes without any output at all. After pressing Ctrl+C I'm getting this:

https://gist.github.com/3456773

I just want to get most of hardware by having CPU_COUNT processes each spawning gevent co-routines. (Yes, I'm sure that I need them all together)

Thanks for any idea ;)




--
This email is intended for the use of the individual addressee(s) named above and may contain information that is confidential, privileged or unsuitable for overly sensitive persons with low self-esteem, no sense of humor or irrational religious beliefs. If you are not the intended recipient, any dissemination, distribution or copying of this email is not authorized (either explicitly or implicitly) and constitutes an irritating social faux pas. Unless the word absquatulation has been used in its correct context somewhere other than in this warning, it does not have any legal or grammatical use and may be ignored. No animals were harmed in the transmission of this email, although the yorkshire terrier next door is living on borrowed time, let me tell you. Those of you with an overwhelming fear of the unknown will be gratified to learn that there is no hidden message revealed by reading this warning backwards, so just ignore that Alert Notice from Microsoft: However, by pouring a complete circle of salt around yourself and your computer you can ensure that no harm befalls you and your pets. If you have received this email in error, please add some nutmeg and egg whites and place it in a warm oven for 40 minutes. Whisk briefly and let it stand for 2 hours before icing.

Oleg Korsak

unread,
Aug 25, 2012, 6:56:59 AM8/25/12
to gev...@googlegroups.com

Oleg Korsak

unread,
Aug 25, 2012, 7:05:51 AM8/25/12
to gev...@googlegroups.com
changing the order doesn't solve the problem

суббота, 25 августа 2012 г., 4:32:27 UTC+3 пользователь Ian E написал:

AM

unread,
Aug 27, 2012, 12:41:11 AM8/27/12
to gev...@googlegroups.com
Hi Oleg.

I think I tried this a while back and IIRC you may need to do a few of
things:

1. Import multiprocessing first, if you actually want to use multiple
processes. BTW multiprocessing will only start cpu_count processes by
default unless you override it in Pool.

2. patch things individually instead of patch_all and dont patch fork
(patch_os) (you may need to leave out patch_thread too) see
http://www.gevent.org/gevent.monkey.html

3. Make sure that none of your code uses fork or threads.

Unfortunately I don't recall if I got it work the way I wanted so YMMV.

HTH
AM

On 08/25/2012 04:05 AM, Oleg Korsak wrote:
> changing the order doesn't solve the problem
>
> суббота, 25 августа 2012 г., 4:32:27 UTC+3 пользователь Ian E написал:
>
> I'm fairly sure you have to monkey patch after you finish all your
> imports. Try moving "frommultiprocessingimportPool" to the top.
>
> Ian Epperson
>
> On Fri, Aug 24, 2012 at 3:55 PM, Oleg Korsak
> <kamikaze.is...@gmail.com <javascript:>> wrote:
>
> Hello, everybody!
> I have a problem while runnung this simple code:
>
> https://gist.github.com/3456736 <https://gist.github.com/3456736>
>
> It just freezes without any output at all. After pressing Ctrl+C
> I'm getting this:
>
> https://gist.github.com/3456773 <https://gist.github.com/3456773>

Oleg Korsak

unread,
Sep 5, 2012, 5:19:52 PM9/5/12
to gev...@googlegroups.com, ams...@gmail.com
Thanks! At least it started working for one thread...

https://gist.github.com/3644941

But now it fails for another reason: https://gist.github.com/3644963

понедельник, 27 августа 2012 г., 7:41:11 UTC+3 пользователь ams.fwd написал:
Reply all
Reply to author
Forward
0 new messages