forked from Aviah/django-queue
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Volumental/feature/query-status
Feature/query status
- Loading branch information
Showing
10 changed files
with
241 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
django_leek/migrations/0004_new_task_structure_20200310_1518.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11 on 2020-03-10 09:18 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('django_leek', '0003_auto_20180910_1028'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Task', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('pickled_task', models.BinaryField(max_length=4096)), | ||
('pool', models.CharField(max_length=256, null=True)), | ||
('queued_at', models.DateTimeField(auto_now_add=True)), | ||
('started_at', models.DateTimeField(null=True)), | ||
('finished_at', models.DateTimeField(null=True)), | ||
('pickled_exception', models.BinaryField(max_length=2048, null=True)), | ||
('pickled_return', models.BinaryField(max_length=4096, null=True)), | ||
], | ||
), | ||
migrations.DeleteModel( | ||
name='FailedTasks', | ||
), | ||
migrations.DeleteModel( | ||
name='QueuedTasks', | ||
), | ||
migrations.DeleteModel( | ||
name='SuccessTasks', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
import base64 | ||
import pickle | ||
from typing import Any | ||
|
||
from django.db import models | ||
|
||
|
||
class QueuedTasks(models.Model): | ||
pickled_task = models.BinaryField(max_length=5000) #max row 65535 | ||
class Task(models.Model): | ||
pickled_task = models.BinaryField(max_length=4096) | ||
pool = models.CharField(max_length=256, null=True) | ||
queued_on = models.DateTimeField(auto_now_add=True) | ||
queued_at = models.DateTimeField(auto_now_add=True) | ||
started_at = models.DateTimeField(null=True) | ||
finished_at = models.DateTimeField(null=True) | ||
pickled_exception = models.BinaryField(max_length=2048, null=True) | ||
pickled_return = models.BinaryField(max_length=4096, null=True) | ||
|
||
@property | ||
def exception(self): | ||
if self.pickled_exception is None: | ||
return None | ||
return pickle.loads(base64.b64decode(self.pickled_exception)) | ||
|
||
@property | ||
def return_value(self): | ||
if self.pickled_return is None: | ||
return None | ||
return pickle.loads(base64.b64decode(self.pickled_return)) | ||
|
||
class SuccessTasks(models.Model): | ||
task_id = models.IntegerField() | ||
saved_on = models.DateTimeField(auto_now_add=True) | ||
def started(self) -> bool: | ||
return self.started_at is not None | ||
|
||
def finished(self) -> bool: | ||
return self.finished_at is not None | ||
|
||
class FailedTasks(models.Model): | ||
task_id = models.IntegerField() | ||
exception = models.CharField(max_length=2048) | ||
saved_on = models.DateTimeField(auto_now_add=True) | ||
def successful(self) -> bool: | ||
return self.finished() and self.pickled_return is not None |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.