Skip to content

a very simple test.py but got "This operation would block forever" #1079

Closed
@Desperatesonic

Description

  • gevent version:
  • Python version: python3.52 Ipython2.4.1
    Linux version 4.4.0-91-generic (buildd@lcy01-11) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) )

Description:

i ran my test.py on the Ipython, the Program result is right ,however I always got " The history saving thread hit an unexpected error (LoopExit('This operation would block forever', <Hub at 0x7f3652773a60 epoll pending=0 ref=0 fileno=8>)).History will not be written to the database. " at first, then the result came out.
my test.py is so easy that i cant find any potential error, by the way , when i ran my test.py on the windows' Spyder(an IDE) , the program didn't come to an end.
Thank you very much if you can answer my question

Remember to put tracebacks in literal blocks

What I've run:

from gevent import monkey; monkey.patch_all()
import gevent
import datetime

def f2(x,i,start):
    while 1:
        x[i]=x[i]+1
        thistime=datetime.datetime.now().timestamp()
        if thistime-start>2.0:
            break
        if x[i]%1000==0:            
            gevent.sleep(0)
    gevent.sleep(0)

b=[0,0,0]
starttime=datetime.datetime.now().timestamp()
gevent.joinall([
        gevent.spawn(f2, b,0,starttime),
        gevent.spawn(f2, b,1,starttime),
        gevent.spawn(f2, b,2,starttime),
])
print(b)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions