/
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
paste
/
util
/
/opt/alt/python37/lib/python3.7/site-packages/paste/util
mkdir
upload
Name
Size
Mode
Actions
looper/
-
0755
rm
template/
-
0755
rm
__pycache__/
-
0755
rm
classinit.py
1849
0644
edit
dl
rm
classinit.pyc
1931
0644
edit
dl
rm
classinit.pyo
1931
0644
edit
dl
rm
classinstance.py
1373
0644
edit
dl
rm
classinstance.pyc
2323
0644
edit
dl
rm
classinstance.pyo
2161
0644
edit
dl
rm
converters.py
863
0644
edit
dl
rm
converters.pyc
1174
0644
edit
dl
rm
converters.pyo
1174
0644
edit
dl
rm
dateinterval.py
2414
0644
edit
dl
rm
dateinterval.pyc
3150
0644
edit
dl
rm
dateinterval.pyo
3150
0644
edit
dl
rm
datetimeutil.py
11170
0644
edit
dl
rm
datetimeutil.pyc
10253
0644
edit
dl
rm
datetimeutil.pyo
10253
0644
edit
dl
rm
doctest24.py
99418
0644
edit
dl
rm
doctest24.pyc
84403
0644
edit
dl
rm
doctest24.pyo
84115
0644
edit
dl
rm
filemixin.py
1431
0644
edit
dl
rm
filemixin.pyc
2062
0644
edit
dl
rm
filemixin.pyo
2062
0644
edit
dl
rm
finddata.py
3841
0644
edit
dl
rm
finddata.pyc
2956
0644
edit
dl
rm
finddata.pyo
2956
0644
edit
dl
rm
findpackage.py
786
0644
edit
dl
rm
findpackage.pyc
914
0644
edit
dl
rm
findpackage.pyo
914
0644
edit
dl
rm
import_string.py
3110
0644
edit
dl
rm
import_string.pyc
3345
0644
edit
dl
rm
import_string.pyo
3345
0644
edit
dl
rm
intset.py
19131
0644
edit
dl
rm
intset.pyc
19532
0644
edit
dl
rm
intset.pyo
19532
0644
edit
dl
rm
ip4.py
9271
0644
edit
dl
rm
ip4.pyc
9243
0644
edit
dl
rm
ip4.pyo
9243
0644
edit
dl
rm
killthread.py
1229
0644
edit
dl
rm
killthread.pyc
1431
0644
edit
dl
rm
killthread.pyo
1431
0644
edit
dl
rm
looper.py.tmpta
3969
0644
edit
dl
rm
mimeparse.py
6592
0644
edit
dl
rm
mimeparse.pyc
7158
0644
edit
dl
rm
mimeparse.pyo
7158
0644
edit
dl
rm
multidict.py
11409
0644
edit
dl
rm
multidict.pyc
16720
0644
edit
dl
rm
multidict.pyo
16720
0644
edit
dl
rm
PySourceColor.py
85865
0644
edit
dl
rm
PySourceColor.pyc
55616
0644
edit
dl
rm
PySourceColor.pyo
55616
0644
edit
dl
rm
quoting.py
2476
0644
edit
dl
rm
quoting.pyc
3014
0644
edit
dl
rm
quoting.pyo
3014
0644
edit
dl
rm
scgiserver.py
5636
0644
edit
dl
rm
scgiserver.pyc
6126
0644
edit
dl
rm
scgiserver.pyo
6015
0644
edit
dl
rm
string24.py
16743
0644
edit
dl
rm
string24.pyc
18685
0644
edit
dl
rm
string24.pyo
18685
0644
edit
dl
rm
template.py.tmpta
24295
0644
edit
dl
rm
threadedprint.py
8211
0644
edit
dl
rm
threadedprint.pyc
10398
0644
edit
dl
rm
threadedprint.pyo
9051
0644
edit
dl
rm
threadinglocal.py
1484
0644
edit
dl
rm
threadinglocal.pyc
2058
0644
edit
dl
rm
threadinglocal.pyo
2058
0644
edit
dl
rm
UserDict24.py
5516
0644
edit
dl
rm
UserDict24.pyc
10513
0644
edit
dl
rm
UserDict24.pyo
10513
0644
edit
dl
rm
__init__.py
86
0644
edit
dl
rm
__init__.pyc
257
0644
edit
dl
rm
__init__.pyo
257
0644
edit
dl
rm
Edit:
/opt/alt/python37/lib/python3.7/site-packages/paste/util/threadedprint.py
(8211B)
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php """ threadedprint.py ================ :author: Ian Bicking :date: 12 Jul 2004 Multi-threaded printing; allows the output produced via print to be separated according to the thread. To use this, you must install the catcher, like:: threadedprint.install() The installation optionally takes one of three parameters: default The default destination for print statements (e.g., ``sys.stdout``). factory A function that will produce the stream for a thread, given the thread's name. paramwriter Instead of writing to a file-like stream, this function will be called like ``paramwriter(thread_name, text)`` for every write. The thread name is the value returned by ``threading.currentThread().getName()``, a string (typically something like Thread-N). You can also submit file-like objects for specific threads, which will override any of these parameters. To do this, call ``register(stream, [threadName])``. ``threadName`` is optional, and if not provided the stream will be registered for the current thread. If no specific stream is registered for a thread, and no default has been provided, then an error will occur when anything is written to ``sys.stdout`` (or printed). Note: the stream's ``write`` method will be called in the thread the text came from, so you should consider thread safety, especially if multiple threads share the same writer. Note: if you want access to the original standard out, use ``sys.__stdout__``. You may also uninstall this, via:: threadedprint.uninstall() TODO ---- * Something with ``sys.stderr``. * Some default handlers. Maybe something that hooks into `logging`. * Possibly cache the results of ``factory`` calls. This would be a semantic change. """ import threading import sys from paste.util import filemixin class PrintCatcher(filemixin.FileMixin): def __init__(self, default=None, factory=None, paramwriter=None, leave_stdout=False): assert len(filter(lambda x: x is not None, [default, factory, paramwriter])) <= 1, ( "You can only provide one of default, factory, or paramwriter") if leave_stdout: assert not default, ( "You cannot pass in both default (%r) and " "leave_stdout=True" % default) default = sys.stdout if default: self._defaultfunc = self._writedefault elif factory: self._defaultfunc = self._writefactory elif paramwriter: self._defaultfunc = self._writeparam else: self._defaultfunc = self._writeerror self._default = default self._factory = factory self._paramwriter = paramwriter self._catchers = {} def write(self, v, currentThread=threading.currentThread): name = currentThread().getName() catchers = self._catchers if not catchers.has_key(name): self._defaultfunc(name, v) else: catcher = catchers[name] catcher.write(v) def seek(self, *args): # Weird, but Google App Engine is seeking on stdout name = threading.currentThread().getName() catchers = self._catchers if not name in catchers: self._default.seek(*args) else: catchers[name].seek(*args) def read(self, *args): name = threading.currentThread().getName() catchers = self._catchers if not name in catchers: self._default.read(*args) else: catchers[name].read(*args) def _writedefault(self, name, v): self._default.write(v) def _writefactory(self, name, v): self._factory(name).write(v) def _writeparam(self, name, v): self._paramwriter(name, v) def _writeerror(self, name, v): assert False, ( "There is no PrintCatcher output stream for the thread %r" % name) def register(self, catcher, name=None, currentThread=threading.currentThread): if name is None: name = currentThread().getName() self._catchers[name] = catcher def deregister(self, name=None, currentThread=threading.currentThread): if name is None: name = currentThread().getName() assert self._catchers.has_key(name), ( "There is no PrintCatcher catcher for the thread %r" % name) del self._catchers[name] _printcatcher = None _oldstdout = None def install(**kw): global _printcatcher, _oldstdout, register, deregister if (not _printcatcher or sys.stdout is not _printcatcher): _oldstdout = sys.stdout _printcatcher = sys.stdout = PrintCatcher(**kw) register = _printcatcher.register deregister = _printcatcher.deregister def uninstall(): global _printcatcher, _oldstdout, register, deregister if _printcatcher: sys.stdout = _oldstdout _printcatcher = _oldstdout = None register = not_installed_error deregister = not_installed_error def not_installed_error(*args, **kw): assert False, ( "threadedprint has not yet been installed (call " "threadedprint.install())") register = deregister = not_installed_error class StdinCatcher(filemixin.FileMixin): def __init__(self, default=None, factory=None, paramwriter=None): assert len(filter(lambda x: x is not None, [default, factory, paramwriter])) <= 1, ( "You can only provide one of default, factory, or paramwriter") if default: self._defaultfunc = self._readdefault elif factory: self._defaultfunc = self._readfactory elif paramwriter: self._defaultfunc = self._readparam else: self._defaultfunc = self._readerror self._default = default self._factory = factory self._paramwriter = paramwriter self._catchers = {} def read(self, size=None, currentThread=threading.currentThread): name = currentThread().getName() catchers = self._catchers if not catchers.has_key(name): return self._defaultfunc(name, size) else: catcher = catchers[name] return catcher.read(size) def _readdefault(self, name, size): self._default.read(size) def _readfactory(self, name, size): self._factory(name).read(size) def _readparam(self, name, size): self._paramreader(name, size) def _readerror(self, name, size): assert False, ( "There is no StdinCatcher output stream for the thread %r" % name) def register(self, catcher, name=None, currentThread=threading.currentThread): if name is None: name = currentThread().getName() self._catchers[name] = catcher def deregister(self, catcher, name=None, currentThread=threading.currentThread): if name is None: name = currentThread().getName() assert self._catchers.has_key(name), ( "There is no StdinCatcher catcher for the thread %r" % name) del self._catchers[name] _stdincatcher = None _oldstdin = None def install_stdin(**kw): global _stdincatcher, _oldstdin, register_stdin, deregister_stdin if not _stdincatcher: _oldstdin = sys.stdin _stdincatcher = sys.stdin = StdinCatcher(**kw) register_stdin = _stdincatcher.register deregister_stdin = _stdincatcher.deregister def uninstall(): global _stdincatcher, _oldstin, register_stdin, deregister_stdin if _stdincatcher: sys.stdin = _oldstdin _stdincatcher = _oldstdin = None register_stdin = deregister_stdin = not_installed_error_stdin def not_installed_error_stdin(*args, **kw): assert False, ( "threadedprint has not yet been installed for stdin (call " "threadedprint.install_stdin())")
Save
cmd:
run