diff --git a/asyncron/gunicorn.py b/asyncron/gunicorn.py index 3a75450..b2ef33f 100644 --- a/asyncron/gunicorn.py +++ b/asyncron/gunicorn.py @@ -30,7 +30,7 @@ def post_fork( server, worker ): #worker and AsyncronWorker, pay attention! AsyncronWorker.init = init -# Keeping the worker in post_fork.worker so we can add extra files it for it to track +# Keeping the worker in post_fork.worker so we can add extra files in it for it to track # TODO: Currently unfinished, since i just realized using the "inotify" support of gunicorn # makes this reduntant, but still here is the relevant code if I want to also support the simpler # polling system diff --git a/asyncron/migrations/0001_initial.py b/asyncron/migrations/0001_initial.py new file mode 100644 index 0000000..666cef5 --- /dev/null +++ b/asyncron/migrations/0001_initial.py @@ -0,0 +1,92 @@ +# Generated by Django 5.1.2 + +import datetime +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('contenttypes', '0002_remove_content_type_name'), + ] + + operations = [ + migrations.CreateModel( + name='Worker', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('pid', models.IntegerField()), + ('thread_id', models.PositiveBigIntegerField()), + ('is_robust', models.BooleanField(default=False)), + ('is_master', models.BooleanField(default=False)), + ('in_grace', models.BooleanField(default=False)), + ('last_crowning_attempt', models.DateTimeField(blank=True, null=True)), + ('consumption_interval_seconds', models.IntegerField(default=10)), + ('consumption_total_active', models.IntegerField(default=0)), + ], + options={ + 'constraints': [models.UniqueConstraint(condition=models.Q(('is_master', True)), fields=('is_master',), name='only_one_master')], + }, + ), + migrations.CreateModel( + name='Task', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.TextField(unique=True)), + ('worker_type', models.CharField(choices=[('A', 'Any'), ('R', 'Robust'), ('D', 'Dynamic')], default='A')), + ('max_completed_traces', models.IntegerField(default=10)), + ('max_failed_traces', models.IntegerField(default=1000)), + ('timeout', models.DurationField(blank=True, default=datetime.timedelta(seconds=300), null=True)), + ('gracetime', models.DurationField(default=datetime.timedelta(seconds=60))), + ('interval', models.DurationField(blank=True, null=True)), + ('jitter_length', models.DurationField(blank=True, default=datetime.timedelta(0))), + ('jitter_pivot', models.CharField(choices=[('S', 'Start'), ('M', 'Middle'), ('E', 'End')], default='M', max_length=1)), + ('worker_lock', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='asyncron.worker')), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='Metadata', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('model_id', models.PositiveIntegerField()), + ('name', models.CharField(max_length=256)), + ('data', models.JSONField(blank=True, null=True)), + ('expiration_datetime', models.DateTimeField(blank=True, null=True)), + ('model_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')), + ], + options={ + 'verbose_name': 'Metadata', + 'verbose_name_plural': 'Metadata', + 'indexes': [models.Index(fields=['model_type', 'model_id'], name='asyncron_me_model_t_d92186_idx')], + }, + ), + migrations.CreateModel( + name='Trace', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status_reason', models.TextField(blank=True, default='')), + ('status', models.CharField(choices=[('S', 'Scheduled'), ('W', 'Waiting'), ('R', 'Running'), ('P', 'Paused'), ('C', 'Completed'), ('A', 'Aborted'), ('E', 'Error')], default='S', max_length=1)), + ('scheduled_datetime', models.DateTimeField(blank=True, null=True)), + ('register_datetime', models.DateTimeField(auto_now_add=True)), + ('last_run_datetime', models.DateTimeField(blank=True, null=True)), + ('last_end_datetime', models.DateTimeField(blank=True, null=True)), + ('protected', models.BooleanField(default=False)), + ('args', models.JSONField(blank=True, default=list)), + ('kwargs', models.JSONField(blank=True, default=dict)), + ('stdout', models.TextField(blank=True, null=True)), + ('stderr', models.TextField(blank=True, null=True)), + ('returned', models.JSONField(blank=True, null=True)), + ('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='asyncron.task')), + ('worker_lock', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='asyncron.worker')), + ], + options={ + 'constraints': [models.UniqueConstraint(condition=models.Q(('scheduled_datetime', None), ('status', 'S')), fields=('task_id',), name='unique_unscheduled_for_task')], + }, + ), + ]