Skip to content

Commit

Permalink
Added task started event
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Collins committed Apr 14, 2020
1 parent 01e54c5 commit aa3bf3b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions labthings/core/tasks/thread.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from gevent import Greenlet, GreenletExit
from gevent.thread import get_ident
from gevent.event import Event
import datetime
import logging
import traceback
Expand Down Expand Up @@ -28,6 +29,9 @@ def __init__(self, target=None, args=None, kwargs=None):
# A UUID for the TaskThread (not the same as the threading.Thread ident)
self._ID = uuid.uuid4() # Task ID

# Event to track if the task has started
self.started_event = Event()

# Make _target, _args, and _kwargs available to the subclass
self._target = target
self._args = args
Expand Down Expand Up @@ -96,6 +100,7 @@ def wrapped(*args, **kwargs):

self._status = "running"
self._start_time = datetime.datetime.now().strftime("%Y-%m-%d %H-%M-%S")
self.started_event.set()
try:
self._return_value = f(*args, **kwargs)
self._status = "success"
Expand Down

0 comments on commit aa3bf3b

Please sign in to comment.