diff options
author | VG <vg@devys.org> | 2016-03-14 15:23:01 +0100 |
---|---|---|
committer | VG <vg@devys.org> | 2016-03-14 15:23:01 +0100 |
commit | 0eb4d62cf3e1b39540c65acd327925aa3c43947b (patch) | |
tree | 78efd6fb9a03c374208ef7d9df17d3d0576d45d1 /tests | |
parent | c4d61b7bfa3e3723ff87df8c163c9d77feeff4f8 (diff) | |
download | wqueue-0eb4d62cf3e1b39540c65acd327925aa3c43947b.tar.gz wqueue-0eb4d62cf3e1b39540c65acd327925aa3c43947b.tar.bz2 wqueue-0eb4d62cf3e1b39540c65acd327925aa3c43947b.zip |
wip
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 10 | ||||
-rw-r--r-- | tests/setup.cfg | 4 | ||||
-rwxr-xr-x | tests/wqueue.py | 11 | ||||
-rwxr-xr-x | tests/wqueue2.py | 46 |
4 files changed, 67 insertions, 4 deletions
diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..6929f5e --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,10 @@ +# static python static checker +# python3-flake8 (pyflakes + python3-pep8) +# pylint3 + +#@python3.5 -m flake8 wqueue2.py => does not support async keyword for now +q= + +test: + $(Q)python3.5 -m pep8 --first . + $(Q)PYTHONASYNCIODEBUG=1 PYTHONUNBUFFERED=1 python3.5 -Wdefault ./wqueue2.py diff --git a/tests/setup.cfg b/tests/setup.cfg new file mode 100644 index 0000000..2ebde94 --- /dev/null +++ b/tests/setup.cfg @@ -0,0 +1,4 @@ +[pep8] +ignore = E121,E123,E126,E226,E24,E704,E265 +show-pep8 = true +exclude = wqueue.py diff --git a/tests/wqueue.py b/tests/wqueue.py index 528a10c..7120bf4 100755 --- a/tests/wqueue.py +++ b/tests/wqueue.py @@ -9,11 +9,14 @@ import asyncio QUEUE_FILE = 'queue.txt' COMMAND = './command.sh' -loop = asyncio.get_event_loop() -class JobHandler(asyncio.SubprocessProtocol): - def process_exited(self): - print() +# loop = asyncio.get_event_loop() + + +# class JobHandler(asyncio.SubprocessProtocol): +# def process_exited(self): +# print() + def do_job(command=None, arg=None): assert(command) diff --git a/tests/wqueue2.py b/tests/wqueue2.py new file mode 100755 index 0000000..d53da36 --- /dev/null +++ b/tests/wqueue2.py @@ -0,0 +1,46 @@ +#!/usr/bin/python3.5 + +import asyncio +import os + +async def test(): + print('sleeping...') + await asyncio.sleep(3) + print('slept') + + +async def manage_client(reader, writer): + print('manage_client created') + print('called on connection only ?') + await asyncio.sleep(1) + print('after sleep1 in server()') + while True: + line = await reader.readline() + if not line: + break + print('line', line) + writer.write(line) + + +def main(): + print('getting event loop') + loop = asyncio.get_event_loop() + print('got event loop') + # loop.call_soon(test) + try: + os.unlink('server_sock') + print('creating coro...') + coro = asyncio.start_unix_server(manage_client, path='server_sock') + print('coro created') + loop.run_until_complete(coro) + print('coro returned') + # loop.run_until_complete(test()) + loop.run_forever() + except KeyboardInterrupt: + pass + print('loop closed') + loop.close() + + +if __name__ == '__main__': + main() |