pombreda / gevent

Automatically exported from code.google.com/p/gevent
0 stars 0 forks source link

gevent 1.0b3: gevent.fileobject.SocketAdapter.sendall() unnecessary blocks on write #150

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the attached script

What is the expected output? What do you see instead?
Script should continually print:

before write
wrote

Instead I see only:

before write
wrote
before write

and then the script hangs.

What version of the gevent are you using?
gevent 1.0b3

On what operating system?
Ubuntu 12.04 LTS

On what Python?
Python 2.7.3

Please provide any additional information below.

Original issue reported on code.google.com by mrkhings...@gmail.com on 15 Aug 2012 at 6:21

Attachments:

GoogleCodeExporter commented 9 years ago
I forgot to mention that if I add the following code in fileobject.py:sendall() 
then it seems to work well for me:

Change:
self.hub.wait(self._write_event)

to:
if bytes_written < bytes_total:
    self.hub.wait(self._write_event)

Not suggesting this as a viable solution to the issue (I don't know enough 
about wha'ts going on in gevent, etc for that), just thought it could help with 
locating the source of the issue.

Thanks :)

Original comment by mrkhings...@gmail.com on 15 Aug 2012 at 6:55

GoogleCodeExporter commented 9 years ago
I agree, it would be good if monkey patching made disk IO non-blocking.

Original comment by flavien....@gmail.com on 22 Aug 2012 at 4:14

GoogleCodeExporter commented 9 years ago
Mark, thanks, you patch is correct: there's no need to wait for write event in 
sendall() if we have already written everything.

Note though, that non-blocking I/O has not effect on regular disk files. So 
FileObject will not help you there, gevent.fileobject.FileObjectThreadPool 
might.

Original comment by Denis.Bi...@gmail.com on 30 Aug 2012 at 8:04

GoogleCodeExporter commented 9 years ago
Can confirm that this is fixed for me in HEAD of gevent. And thanks for the tip 
about FileObjectThreadPool - that does seem to be what I actually want (my 
usage is very similar to what was asked about in: 
http://stackoverflow.com/questions/11496996/python-gevent-i-dont-see-monkey-patc
hed-the-default-file-open-read-write-close)

Original comment by mark.hin...@vardr.com on 31 Aug 2012 at 12:29

GoogleCodeExporter commented 9 years ago
Migrated to http://github.com/SiteSupport/gevent/issues/150

Original comment by Denis.Bi...@gmail.com on 14 Sep 2012 at 10:53