[py-svn] r13690 - py/branch/execnet-refactoring
arigo at codespeak.net
arigo at codespeak.net
Wed Jun 22 13:08:57 CEST 2005
Author: arigo
Date: Wed Jun 22 13:08:56 2005
New Revision: 13690
Modified:
py/branch/execnet-refactoring/gateway.py
Log:
Relying on Python's refcounting to close channels doesn't sound like such a
great idea. This is what causes troubles in "py.test --exec=python2.4".
Trying a (probably too implicit) solution: remote_exec() will by default
automatically close the channel on the remote side after it finished
executing, unless the "channel=.." argument is passed to remote_exec(), in
which case we assume the user wants better control over the channel.
Modified: py/branch/execnet-refactoring/gateway.py
==============================================================================
--- py/branch/execnet-refactoring/gateway.py (original)
+++ py/branch/execnet-refactoring/gateway.py Wed Jun 22 13:08:56 2005
@@ -137,7 +137,7 @@
channel.close()
return close
- def thread_executor(self, channel, (source, outid, errid)):
+ def thread_executor(self, channel, (source, outid, errid, autoclose)):
""" worker thread to execute source objects from the execution queue. """
from sys import exc_info
try:
@@ -159,12 +159,15 @@
channel.close(errortext)
self.trace(errortext)
else:
- # the channel should usually be closed by Channel.__del__.
- # Give it a better chance now.
- try:
- del loc['channel']
- except KeyError:
- pass
+ if autoclose:
+ channel.close()
+ else:
+ # the channel should usually be closed by Channel.__del__.
+ # Give it a better chance now.
+ try:
+ del loc['channel']
+ except KeyError:
+ pass
def _local_schedulexec(self, channel, sourcetask):
self.trace("dispatching exec")
@@ -207,10 +210,13 @@
pass
if channel is None:
channel = self.newchannel()
+ autoclose = True
+ else:
+ autoclose = False
outid = self._newredirectchannelid(stdout)
errid = self._newredirectchannelid(stderr)
self._outgoing.put(Message.CHANNEL_OPEN(channel.id,
- (source, outid, errid)))
+ (source, outid, errid, autoclose)))
return channel
def remote_redirect(self, stdout=None, stderr=None):
More information about the pytest-commit
mailing list