Daemon now must be async (more consistent)
parent
f6f081bfba
commit
e7637a1bce
|
@ -1,3 +1,7 @@
|
|||
## Unreleased
|
||||
### Added
|
||||
- Daemons can now accept an interval value, removing the need for a manual while True loop
|
||||
|
||||
## v0.1 (2020/08/26)
|
||||
|
||||
### Added
|
||||
|
|
|
@ -122,7 +122,7 @@ class Daemon(Simple):
|
|||
if interval > 0:
|
||||
async def loop(self, *args, **kwargs):
|
||||
while True:
|
||||
func(self, *args, **kwargs)
|
||||
await func(self, *args, **kwargs)
|
||||
|
||||
await asyncio.sleep(interval)
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
# =====IMPORTS=====
|
||||
# Third-party imports
|
||||
import pytest
|
||||
|
||||
# Own imports
|
||||
from frank import default, command, daemon
|
||||
|
||||
|
@ -27,7 +30,7 @@ class TestDecorators:
|
|||
return 'daemon'
|
||||
|
||||
@daemon()
|
||||
def daemon_dec(self):
|
||||
async def daemon_dec(self):
|
||||
return self.daemon_no_dec()
|
||||
|
||||
def test_default(self):
|
||||
|
@ -36,5 +39,6 @@ class TestDecorators:
|
|||
def test_command(self):
|
||||
assert self.command_no_dec() == self.command_dec()
|
||||
|
||||
def test_daemon(self):
|
||||
assert self.daemon_no_dec() == self.daemon_dec()
|
||||
@pytest.mark.asyncio
|
||||
async def test_daemon(self):
|
||||
assert self.daemon_no_dec() == await self.daemon_dec()
|
||||
|
|
Reference in New Issue