David Wilson
961a9549bd
Better method to ensure __module__ is set consistently.
...
PyFunction_New() and type_new() both simply lookup the __name__ of the
global scope in which a function or class is defined in order to
determine its __module__. So we can do a better job of ensuring
__module__ is set correctly by simply overriding __name__ before
defining any functions or classes.
Works identically in Python 3.
8 years ago
David Wilson
571cc00dc3
Import incomplete econtext.tcp implementation.
8 years ago
David Wilson
fe171cd8cf
Parameterize create_child() in order to support non-pipe children.
8 years ago
David Wilson
ae7fcb75e4
Fix run_with_broker test.
8 years ago
David Wilson
959839cbbf
Fix log message.
8 years ago
David Wilson
5a4fc577cd
disable_site_packages() helper for ssh_test.
8 years ago
David Wilson
341a90e173
Allow setting ssh_path in econtext.ssh.connect().
8 years ago
David Wilson
7465e5b283
Add missing econtext.ssh to present list.
8 years ago
David Wilson
bdc2f291ca
Some importers don't implement all the optional interfaces.
8 years ago
David Wilson
ff903b1bcd
Rearrange docs, split connection methods into submodules.
8 years ago
David Wilson
87a4206015
Enhance utils.log_to_file().
8 years ago
David Wilson
81dd265c20
Catch BaseException to cope with KeyboardInterrupt and suchlike.
...
Django's module autoreloader calls sys.exit(), we want to catch that.
8 years ago
David Wilson
965350757f
Import working (but useless) connection plugin.
8 years ago
David Wilson
481ae1a933
Implement Importer.get_filename() and Importer.get_source()
...
Optional importer protocols required for Python to display annotated
tracebacks.
8 years ago
David Wilson
30991a6b42
Cure flake8 error.
8 years ago
David Wilson
ee56032758
Last ditch attempt to log main() thread crashes.
8 years ago
David Wilson
013634a317
Python2.4 lacks any().
8 years ago
David Wilson
d2829259a5
Python 3 compatible first stage.
8 years ago
David Wilson
e4efcd9455
Don't do bool(source) as some modules are 0 bytes.
8 years ago
David Wilson
9e68408597
Draft importer tests.
8 years ago
David Wilson
301972bc57
Restructure module importer to cope with Ansible.
8 years ago
David Wilson
5ccf90702e
Use sys.executable for LocalStream.python_path by default
...
But still use just 'python' for SshStream.
8 years ago
David Wilson
d4478ca25c
Don't use minimize_source() on third party code.
...
It breaks at least indentation.
8 years ago
David Wilson
9d6d342af1
Add CallError to the permitted classes list.
8 years ago
David Wilson
3de06ca559
"Ansible compatible" module loader.
...
Since all Ansible modules ever written are using worst practice Python,
the module loader must be rewritten to cope with their horrors.
Ansible is woeful software:
* AnsibleModule argument declarations appear within the main() function,
so they can't be introspected prior to execution.
* No if __name__ == '__main__' guard means they can't be introspected
without triggering execution.
* By default the main() function attempts to read from stdin, hanging
our IO thread.
* So much unspeakable crap.
This rewrites the module loader to avoid actually running a module if it
can possibly be avoided. The downside is that the new loader must be
aware of far more details of the Python module mechanism. For example
with the new importer, namespace packages are broken at the very least.
On the plus side, now the module loader will be able to cope with
Django.
8 years ago
David Wilson
088d053a4e
Fix Waker repr.
8 years ago
David Wilson
2225ee2923
Convert CallError received on channel into exception.
8 years ago
David Wilson
e7c4736b78
Better handle unpicklable objects.
8 years ago
David Wilson
82401c7274
Catch _run_on_thread crashes.
8 years ago
David Wilson
a26a6bd66e
More docs.
8 years ago
David Wilson
ec21caa098
IOLOG re.
8 years ago
David Wilson
ba3a0b6c48
Fix line numbers.
8 years ago
David Wilson
fea12a6030
Many updates: graceful shutdown, docs, threading
...
* Start splitting docs up into internals.rst / api.rst
* Docs for lots more of econtext.core.
* Get rid of _update_stream() and has_output(), replace with individual
functions called as state changes.
* Add Broker.on_thread() and remove Stream._lock: simply call
on_thread() to ensure buffer management is linearized.
* Rename read_side/write_side to receive_side/transmit_side like event
handler names.
* Clean up some more repr / debug logs.
* Move handle cleanup to Context.on_shutdown where it belongs.
* Make wake() a noop when called from broker thread.
* Replace graceful_count crap with Side.graceful attribute, add
Broker.keep_alive() to check whether any registered readers want to
be kept alive for graceful shutdown() or any child contexts with a
connected stream exist.
* Make master.Broker timeout slightly longer than slave broker.
* Add generic on_thread() to allow running code on the IO thread.
8 years ago
David Wilson
f83c7c4802
Don't bury EBADF errors.
8 years ago
David Wilson
5cc60b4bb3
log_to_file() sets econtext.io log level too.
8 years ago
David Wilson
54b97b12ac
Remove pointless _put_reply wrapper.
8 years ago
David Wilson
7c80ca37fd
Replace Context lock with code that always runs under GIL
8 years ago
David Wilson
a8928b8e05
Remove completely pointless _update_stream lock.
8 years ago
David Wilson
9b4183ddc4
Fix another race.
...
on_transmit() buffer mutation must be linearized with enqueue() buffer
mutation.
8 years ago
David Wilson
0e38d1f3e3
Remove needless long prefix.
8 years ago
David Wilson
ac2a52587b
s/wait/join/
8 years ago
David Wilson
54b0a0aed7
Gracefully handle callback crashes.
8 years ago
David Wilson
2703e444ef
Module importer fixes.
...
* Use TLS to track whether importer is currently running. Avoids
needing to maintain an ignore stack.
* Print more debugging around cases where Importer skips a module.
* If a module is part of a package, import the package and examine its
__loader__. If we are not the loader, refuse to load it.
8 years ago
David Wilson
e422dedab8
Replace private lock with global importer lock.
8 years ago
David Wilson
f88b0a11e9
Python 2.4 fixes.
8 years ago
David Wilson
1bc8681cb4
More doc updates.
8 years ago
David Wilson
1f27872eda
Many docs updates.
8 years ago
David Wilson
6a01ae03e3
Replace SHUTDOWN with Channel.send(_DEAD)
8 years ago
David Wilson
95902d94b0
Python 2.5 fix: Logger.getChild() does not exist there.
8 years ago
David Wilson
da4e457247
More docs, move call/call_with_deadline to econtext.master.
8 years ago
David Wilson
c607831561
SlaveModuleImporter->Importer, enable intersphinx, finish howitworks.rst.
8 years ago
David Wilson
737d095ffc
More docs.
8 years ago
David Wilson
62520b1bcb
Write history section.
8 years ago
David Wilson
63ee222406
Many docs updates.
8 years ago
David Wilson
8ba5fbf27f
Get rid of CorruptMessageError.
8 years ago
David Wilson
73c418ef4b
Rename ContextError -> Error.
8 years ago
David Wilson
052c96d7ee
Allow importing master's __main__.
8 years ago
David Wilson
8afa1327fb
Move wait() to correct location.
8 years ago
David Wilson
dd03183022
Remove needless setup work.
8 years ago
David Wilson
ce27058bdf
Initial intro doc.
8 years ago
David Wilson
d457c20d87
Naming/docstring tidyups.
8 years ago
David Wilson
d2fa9ba2aa
Tidy.
8 years ago
David Wilson
cc18ab5e28
Tidy up event names and docstrings.
8 years ago
David Wilson
663eb01518
Docstring fixes.
8 years ago
David Wilson
d6d13ee506
Rationalize _fixup_package(), fix _setup_master() name.
8 years ago
David Wilson
0e58a48611
Fix method naming everywhere.
8 years ago
David Wilson
4b11023558
flake8
8 years ago
David Wilson
6f1b6df0f9
Don't leak slave's main IO streams.
8 years ago
David Wilson
70c2032bb2
Another hackish graceful shutdown method.
8 years ago
David Wilson
4e5add97e5
Seemingly robust graceful shutdown.
8 years ago
David Wilson
98f5cdc9fc
Tweak timeotu.
8 years ago
David Wilson
9a8fc5e167
Another attempt at graceful shutdown.
8 years ago
David Wilson
4947fb2c40
Rename PutReply for log readability.
8 years ago
David Wilson
397275087b
Fix name.
8 years ago
David Wilson
f4fa69075e
Remove unused signal.signal().
8 years ago
David Wilson
14b0b0d008
Remove unused ReadMore().
8 years ago
David Wilson
4bf9d35e74
Better LocalStream bootstrap failure message.
8 years ago
David Wilson
8216edd755
Quieter logging of ImportError.
8 years ago
David Wilson
fa0beffac2
Fix stdout reopen when stdout is a socket.
8 years ago
David Wilson
625bec9db5
Remove wait= from Finalize(), main() try/except.
8 years ago
David Wilson
d9e9d94f30
GetLocal(python_path=...)
8 years ago
David Wilson
d8b6aa8902
Beginnings of graceful shutdown.
8 years ago
David Wilson
8a081a103f
Python 2.4 open() vs. file().
8 years ago
David Wilson
82a31cfb7a
Tidy up _ReceiveOne() logic.
8 years ago
David Wilson
f93839c318
Fix variable name.
8 years ago
David Wilson
7683ee060e
Split out GetPreamble.
8 years ago
David Wilson
8fdedff8e7
Do docstring and comment removal before compression.
8 years ago
David Wilson
d4875fdec7
Fix obvious importer bug.
8 years ago
David Wilson
bca3a65157
Use set_cloexec() everywhere.
8 years ago
David Wilson
6bedfe1934
Fix input length check error.
8 years ago
David Wilson
eeecf0f984
Simplify module loader (master already checked in)
8 years ago
David Wilson
1d4e63947f
Remove finalize_on_disconnect.
8 years ago
David Wilson
274f7f91a3
Oops, forgot to check in master.py.
8 years ago
David Wilson
054e74c952
Remove ancient stuff.
8 years ago
David Wilson
c6b0bdf12e
Try harder to avoid roundtrips for missing modules.
8 years ago
David Wilson
ae3316b985
Split into core and master modules.
8 years ago
David Wilson
dc231847a0
Add absent package cache.
8 years ago
David Wilson
5775f9791c
Fix package imports.
8 years ago
David Wilson
27a1c9b182
Better default remote context name.
8 years ago
David Wilson
081565358d
utils.run_with_broker.
8 years ago