Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7066494
D967.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D967.diff
View Options
diff --git a/swh/scheduler/task.py b/swh/scheduler/task.py
--- a/swh/scheduler/task.py
+++ b/swh/scheduler/task.py
@@ -30,6 +30,12 @@
self._log = get_task_logger(self.name)
return self._log
+ def run(self, *args, **kwargs):
+ self.log.debug('%s: args=%s, kwargs=%s', self.name, args, kwargs)
+ ret = super().run(*args, **kwargs)
+ self.log.debug('%s: OK => %s', self.name, ret)
+ return ret
+
class Task(SWHTask):
"""a schedulable task (abstract class)
diff --git a/swh/scheduler/tests/tasks.py b/swh/scheduler/tests/tasks.py
--- a/swh/scheduler/tests/tasks.py
+++ b/swh/scheduler/tests/tasks.py
@@ -1,10 +1,7 @@
-from celery import group
+from celery import group, current_app as app
-from swh.scheduler.celery_backend.config import app
-
-@app.task(name='swh.scheduler.tests.tasks.ping',
- bind=True)
+@app.task(name='swh.scheduler.tests.tasks.ping', bind=True)
def ping(self, **kw):
# check this is a SWHTask
assert hasattr(self, 'log')
@@ -16,26 +13,19 @@
return 'OK'
-@app.task(name='swh.scheduler.tests.tasks.multiping',
- bind=True)
+@app.task(name='swh.scheduler.tests.tasks.multiping', bind=True)
def multiping(self, n=10):
- self.log.debug(self.name)
-
promise = group(ping.s(i=i) for i in range(n))()
self.log.debug('%s OK (spawned %s subtasks)' % (self.name, n))
promise.save()
return promise.id
-@app.task(name='swh.scheduler.tests.tasks.error',
- bind=True)
-def not_implemented(self):
- self.log.debug(self.name)
+@app.task(name='swh.scheduler.tests.tasks.error')
+def not_implemented():
raise NotImplementedError('Nope')
-@app.task(name='swh.scheduler.tests.tasks.add',
- bind=True)
-def add(self, x, y):
- self.log.debug(self.name)
+@app.task(name='swh.scheduler.tests.tasks.add')
+def add(x, y):
return x + y
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Nov 5 2024, 12:21 PM (12 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3222343
Attached To
D967: Add debug logging in the SWHTask class
Event Timeline
Log In to Comment