Improve asyncio usage
This commit is contained in:
parent
43f43a4137
commit
e5339d264c
2 changed files with 12 additions and 13 deletions
|
@ -122,7 +122,7 @@ async def _sleep():
|
|||
await asyncio.sleep(360)
|
||||
|
||||
|
||||
def _main():
|
||||
async def _main():
|
||||
_validate_config()
|
||||
|
||||
keyring_path = conf.get_item('gpg', 'keyhome')
|
||||
|
@ -132,16 +132,16 @@ def _main():
|
|||
|
||||
mode = conf.get_item('keyring', 'type')
|
||||
|
||||
keyring = kcache.init_keyring(mode, loop = loop)
|
||||
controller = _init_controller(keyring, max_data_bytes)
|
||||
|
||||
keyring.post_init_hook()
|
||||
|
||||
LOG.info('Starting the daemon...')
|
||||
controller.start()
|
||||
|
||||
try:
|
||||
loop.run_until_complete(_sleep())
|
||||
keyring = kcache.init_keyring(mode, loop = loop)
|
||||
controller = _init_controller(keyring, max_data_bytes)
|
||||
|
||||
keyring.post_init_hook()
|
||||
|
||||
LOG.info('Starting the daemon...')
|
||||
controller.start()
|
||||
|
||||
await _sleep()
|
||||
except KeyboardInterrupt:
|
||||
LOG.info("Finishing...")
|
||||
except:
|
||||
|
@ -155,4 +155,4 @@ def _main():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_main()
|
||||
asyncio.run(_main())
|
||||
|
|
|
@ -54,8 +54,7 @@ class FileKeyRing(KeyRing):
|
|||
def load(self):
|
||||
"""Load keyring, replacing any previous contents of the cache."""
|
||||
LOG.debug('Reloading keys...')
|
||||
tsk = create_task(self._load(), 'LoadTask')
|
||||
self._loop.run_until_complete(tsk)
|
||||
return create_task(self._load(), 'LoadTask')
|
||||
|
||||
async def _load(self):
|
||||
last_mod = self._read_mod_time()
|
||||
|
|
Loading…
Reference in a new issue