moobius.core.wand#
Module-level functions#
sigint_handler#
Exits using a special error code that the parent process will recognize as a “Ctrl+C” interrupt..
**sigint_handler**(signal, frame)
__signal:__ Integer signal.
__frame:__ Stack frame.
The os._exit.
(this function does not raise any notable errors)
Class MoobiusWand#
Starts and manages services. It can also be used to send messages to a service using the spell() function or the async aspell() function.
- The typical use-case and suggested file paths:
>>> wand = MoobiusWand() >>> handle = wand.run(MyService, config_path="config/service.json", db_config_path="config/db.json", >>> log_file="logs/service.log", error_log_file="logs/error.log", terminal_log_level="INFO", >>> is_agent=False, background=True) >>> wand.spell(handle, xyz_message) # Use to send data to the service.
MoobiusWand.run_job#
Runs service.start(), which blocks in an infinite loop, using asyncio.
**MoobiusWand.run_job**(service)
__service:__ Moobius service.
The Never.
(this function does not raise any notable errors)
MoobiusWand.run#
Starts a service or agent, either on the same process in a blocking infinite loop or on another process.
**MoobiusWand.run**(self, cls, background, kwargs)
__cls:__ A subclass of the Moobius class but NOT an instance.
__background:__ If True, runs on another Process.
__kwargs=False:__ Kwargs passed to the constructor of cls.
None.
(this function does not raise any notable errors)
MoobiusWand.stop_all#
Stops all processes using the_process.kill().. Also stops the asyncio event loop.
**MoobiusWand.stop_all**(self, force_exit)
__force_exit=False:__ N option to force-quit.
The exit.
(this function does not raise any notable errors)
MoobiusWand.spell#
Sends a message to a service by putting to it’s aioprocessing.AioQueue().
**MoobiusWand.spell**(self, handle, obj)
__handle:__ The handle of the service created by the run() function.
__obj:__ The message to be sent.
None.
(this function does not raise any notable errors)
MoobiusWand.aspell#
Async version of spell(), uses q.coro_put(obj) instead of q.put(obj) where q = self.services[handle].queue..
**MoobiusWand.aspell**(self, handle, obj)
__handle:__ Handle int.
__obj:__ The generic pickleable object.
None.
(this function does not raise any notable errors)