| Server IP : 85.214.239.14 / Your IP : 216.73.216.41 Web Server : Apache/2.4.65 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /srv/modoboa/env/lib/python3.5/site-packages/gevent/tests/ |
Upload File : |
from __future__ import print_function
import sys
if not sys.argv[1:]:
from subprocess import Popen, PIPE
p = Popen([sys.executable, __file__, 'subprocess'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
out, err = p.communicate(b'hello world\n')
code = p.poll()
assert p.poll() == 0, (out, err, code)
assert out.strip() == b'11 chars.', (out, err, code)
# XXX: This is seen sometimes to fail on Travis with the following value in err but a code of 0;
# it seems load related:
# 'Unhandled exception in thread started by \nsys.excepthook is missing\nlost sys.stderr\n'.
# If warnings are enabled, Python 3 has started producing this:
# '...importlib/_bootstrap.py:219: ImportWarning: can't resolve package from __spec__
# or __package__, falling back on __name__ and __path__\n return f(*args, **kwds)\n'
assert err == b'' or b'sys.excepthook' in err or b'Warning' in err, (out, err, code)
elif sys.argv[1:] == ['subprocess']: # pragma: no cover
import gevent
import gevent.monkey
gevent.monkey.patch_all(sys=True)
def printline():
try:
line = raw_input()
except NameError:
line = input()
print('%s chars.' % len(line))
gevent.spawn(printline).join()
else: # pragma: no cover
sys.exit('Invalid arguments: %r' % (sys.argv, ))