Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

aiogear

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aiogear - pypi Package Compare versions

Comparing version
0.1.3
to
0.1.4
+1
-1
aiogear.egg-info/PKG-INFO
Metadata-Version: 1.1
Name: aiogear
Version: 0.1.3
Version: 0.1.4
Summary: Asynchronous gearman protocol based on asyncio

@@ -5,0 +5,0 @@ Home-page: https://github.com/sardok/aiogear

@@ -19,6 +19,7 @@ import asyncio

self.transport = None
self.task = None
self.main_task = None
self.functions = OrderedDict()
self.running = WeakValueDictionary()
self.waiters = []
self.shutting_down = False

@@ -52,3 +53,3 @@ grab_mapping = {

self.can_do(fname)
self.task = self.get_task()
self.main_task = self.get_task(self.run())

@@ -58,8 +59,8 @@ def connection_lost(self, exc):

def get_task(self):
return asyncio.Task(self.run())
def get_task(self, coro):
return asyncio.ensure_future(coro, loop=self.loop)
async def run(self,):
no_job = NoJob()
while True:
while not self.shutting_down:
self.pre_sleep()

@@ -84,3 +85,3 @@ await self.wait_for(Type.NOOP)

if asyncio.iscoroutine(result_or_coro):
task = asyncio.ensure_future(result_or_coro, loop=self.loop)
task = self.get_task(result_or_coro)
self.running[job_info.handle] = task

@@ -94,2 +95,4 @@ result = await task

self.work_exception(job_info.handle, str(ex))
finally:
self.running.pop(job_info.handle, None)

@@ -99,16 +102,21 @@ except AttributeError:

async def shutdown(self):
logger.debug('Shutting down worker ...')
async def cancel_and_wait(tasks):
if not tasks:
return
for task in tasks:
task.cancel()
try:
await asyncio.wait(tasks, loop=self.loop)
except asyncio.CancelledError:
pass
async def shutdown(self, graceful=False):
logger.debug('Shutting down worker {}gracefully...'.format('' if graceful else 'un'))
self.shutting_down = True
sub_tasks = list(self.running.values())
if graceful:
if sub_tasks:
await asyncio.wait(sub_tasks, loop=self.loop)
else:
async def cancel_and_wait(tasks):
for task in tasks:
task.cancel()
try:
await asyncio.wait(tasks, loop=self.loop)
except asyncio.CancelledError:
pass
if sub_tasks:
await cancel_and_wait(sub_tasks)
self.main_task.cancel()
await cancel_and_wait(list(self.running.values()))
await cancel_and_wait([self.task])
if self.transport:

@@ -115,0 +123,0 @@ self.transport.close()

Metadata-Version: 1.1
Name: aiogear
Version: 0.1.3
Version: 0.1.4
Summary: Asynchronous gearman protocol based on asyncio

@@ -5,0 +5,0 @@ Home-page: https://github.com/sardok/aiogear

@@ -5,3 +5,3 @@ from setuptools import setup

name='aiogear',
version='0.1.3',
version='0.1.4',
author='Sinan Nalkaya',

@@ -8,0 +8,0 @@ author_email='sardok@gmail.com',