mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 18:03:31 +01:00
Add Process and Signals support
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
6123a68195
commit
c96ffe52c0
6 changed files with 139 additions and 0 deletions
4
tools/python/jwutils/asyncio/Makefile
Normal file
4
tools/python/jwutils/asyncio/Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
TOPDIR = ../../../..
|
||||
|
||||
include $(TOPDIR)/make/proj.mk
|
||||
include $(JWBDIR)/make/py-mod.mk
|
||||
20
tools/python/jwutils/asyncio/Process.py
Normal file
20
tools/python/jwutils/asyncio/Process.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from abc import abstractmethod
|
||||
|
||||
from ..Process import Process as ProcessBase
|
||||
from .Signals import Signals
|
||||
|
||||
class Process(ProcessBase): # export
|
||||
|
||||
__signals = Signals()
|
||||
|
||||
def __init__(self, aio):
|
||||
super().__init()
|
||||
self.aio = aio
|
||||
|
||||
@classmethod
|
||||
@abstractmethod
|
||||
def signals(cls):
|
||||
return cls.__signals
|
||||
|
||||
def wait(self):
|
||||
return self.aio.wait()
|
||||
10
tools/python/jwutils/asyncio/Signals.py
Normal file
10
tools/python/jwutils/asyncio/Signals.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import asyncio
|
||||
from ..Signals import Signals as SignalsBase
|
||||
|
||||
class Signals(SignalsBase):
|
||||
|
||||
# reimplemented from Signals
|
||||
@classmethod
|
||||
def _add_handler(cls, signal, handler):
|
||||
loop = asyncio.get_running_loop()
|
||||
loop.add_signal_handler(signal, handler, None) # None = *args
|
||||
3
tools/python/jwutils/asyncio/__init__.py
Normal file
3
tools/python/jwutils/asyncio/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# >> -------------------------- generated by python-tools.sh >>
|
||||
from jwutils.asyncio.Process import Process
|
||||
# << -------------------------- generated by python-tools.sh <<
|
||||
Loading…
Add table
Add a link
Reference in a new issue