Simple example raise OSError: [Errno 9] Bad file descriptor.
Issue #27
invalid
Hi, I try work with you solution and get a strange behavior.
My test_sarger.py
:
from sarge import Feeder, run, Capture
feeder = Feeder()
pipe = run('cat | python -c "while 1: print(input().upper())"', input=feeder, stdout=Capture(), stderr=Capture(), async=True)
feeder.feed('Hello')
feeder.feed(b'Goodbye')
feeder.close()
pipe.wait()
print(pipe.stdout.text)
# print(pipe.stderr.text)
When I run it and in 1/10 case I have got an error:
(venv)root@precise64:/vagrant# python test_sarger.py
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner
self.run()
File "/usr/lib/python3.2/threading.py", line 693, in run
self._target(*self._args, **self._kwargs)
File "/var/lib/wflow/venv/lib/python3.2/site-packages/sarge/__init__.py", line 1136, in run_node
result = getattr(self, method)(node, input, async)
File "/var/lib/wflow/venv/lib/python3.2/site-packages/sarge/__init__.py", line 1247, in run_logical_node
curr.cmd.run(input=stdin, async=use_async)
File "/var/lib/wflow/venv/lib/python3.2/site-packages/sarge/__init__.py", line 632, in run
self.process = p = Popen(self.args, **self.kwargs)
File "/usr/lib/python3.2/subprocess.py", line 745, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.2/subprocess.py", line 1361, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 9] Bad file descriptor
Is this a normal behavior?
Comments (4)
-
reporter -
reporter -
repo owner I am not sure if a
wait_events()
call should be added here - it may be that the caller ofrun
wants to do other work, and only needs to wait for all the events at a later time. This could be mentioned in the documentation. If we implement this call here, we are forcing the caller to synchronise when they may not want to. -
repo owner - changed status to invalid
Closing as invalid - I don't think it's a bug.
- Log in to comment
I found the solution and probably problem reason:
The main problem solver is
pipe.wait_events()
. I think that main problem infeeder.close()
, because withoutpipe.wait_events()
command proces may start after feeder is closed.pipe.wait_events()
- sync point for all the commands have been created.But now, I have a new issuse: https://bitbucket.org/vinay.sajip/sarge/issue/28/eoferror-eof-when-reading-a-line