Skip to content

Commit

Permalink
Merge pull request #104 from phenobarbital/new-version
Browse files Browse the repository at this point in the history
fix when task is not created (avoid close)
  • Loading branch information
phenobarbital committed Apr 22, 2023
2 parents 627ac87 + 36bfb73 commit d195b69
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 132 deletions.
4 changes: 4 additions & 0 deletions qw/exceptions.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ cdef class ParserError(QWException):
cdef class DiscardedTask(QWException):
"""Usable to patch Discarded tasks."""
pass

cdef class ProcessNotFound(QWException):
"""Process was not found."""
pass
4 changes: 4 additions & 0 deletions qw/exceptions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ cdef class ParserError(QWException):
cdef class DiscardedTask(QWException):
def __init__(self, str message = None):
super().__init__(message or f"Task was Discarded", status=408)

cdef class ProcessNotFound(QWException):
def __init__(self, str message = None):
super().__init__(message or f"Task Not Found", status=404)
5 changes: 1 addition & 4 deletions qw/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,7 @@ async def run_task(self, task: TaskWrapper):
except Exception as err: # pylint: disable=W0703
result = err
finally:
try:
await task.close()
except Exception: # pylint: disable=W0703
pass
await task.close()
print(f'RUN TASK {task!s} RESULT> ', result)
return result

Expand Down
2 changes: 1 addition & 1 deletion qw/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__title__ = 'qworker'
__description__ = ('QueueWorker is asynchronous Task Queue implementation built on to of Asyncio.'
'Can you spawn distributed workers to run functions inside workers.')
__version__ = '1.6.3'
__version__ = '1.6.4'
__author__ = 'Jesus Lara'
__author_email__ = 'jesuslarag@gmail.com'
__license__ = 'MIT'
Expand Down
122 changes: 0 additions & 122 deletions qw/wrappers/di.py

This file was deleted.

16 changes: 11 additions & 5 deletions qw/wrappers/di_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
logging.warning(
"Unable to Load DataIntegrator Task Component, we can't send DI Tasks to any Worker."
)
from qw.exceptions import ProcessNotFound, QWException
from .base import QueueWrapper

class TaskWrapper(QueueWrapper):
Expand Down Expand Up @@ -60,13 +61,17 @@ async def create(self):
debug=self._debug,
**self.kwargs
)
except TaskNotFound:
raise
except TaskNotFound as ex:
raise ProcessNotFound(
f"Task Not Found: {ex}"
)
except TaskError:
raise
except Exception as err:
logging.exception(err, stack_info=True)
raise
raise QWException(
f"{err}"
) from err

def __await__(self):
return self.__call__().__await__()
Expand Down Expand Up @@ -118,8 +123,9 @@ async def run(self):

async def close(self):
try:
await self._task.close()
del self._task
if self._task:
await self._task.close()
self._task = None
except Exception as err: # pylint: disable=W0703
logging.error(err)

Expand Down
Binary file modified templates/.compiled
Binary file not shown.

0 comments on commit d195b69

Please sign in to comment.