Git Product home page Git Product logo

django-simple-task's People

Contributors

dependabot[bot] avatar ericls avatar raratiru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-simple-task's Issues

Daphne not working with django-simple-task?

If I run a fairly simple django app (which I'll try to get pushed to a sample repo on github at some point) that follows your instructions, when running the django app via Daphne, Daphne doesn't send a scope["type"] == lifetime event, and as a result, the queue/loop values don't get set, so when defer is called, the loop doesn't get used and the function just finishes (so the deferred "func" isn't called); swapping uvicorn for Daphne and django-simple-task works as advertised. Reading quickly the ASGI spec, I think Daphne isn't following the suggested lifetime bit, but I could be missing something. Anyways, I would suggest:
A) If you've tested it with Daphne, documenting any extra steps required
B) If I'm correct and uvicorn is doing the asgi spec the way django-simple-task expects, recommend using that.
C) Modifying task.py's defer so that if loop isn't defined, it at least logs that there was no queue to save this func to run (or possibly just call the func inline?)

Django-4.1 Warning - Tests for Python-3.10 and Django-4.0

The following deprecation warning appears for:

default_app_config = "django_simple_task.apps.DjangoSimpleTaskConfig"

RemovedInDjango41Warning: 
    'django_simple_task' defines default_app_config = 'django_simple_task.apps.DjangoSimpleTaskConfig'. 
    Django now detects this configuration automatically. You can remove default_app_config.
    app_config = AppConfig.create(entry)

Will django-simple-task run for Django-4.0 and Python-3.10?

matrix:
python-version: [3.7, 3.8, 3.9]
django-version: [3.1, 3.2]

I follow the docs example,but task is not running

System:

  • MacOX
    Requirement:
  • Django==3.0.1
  • daphne==2.4.1
    StartCommand:
  • daphne src.asgi:application
    Description:
  • When I visit localhost:8000/test,the task is not running.
# asgi.py
import os
from django.core.asgi import get_asgi_application
from django_simple_task import django_simple_task_middlware

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings')

application = get_asgi_application()

application = django_simple_task_middlware(application)
# views.py
import time
from django.shortcuts import HttpResponse
from django_simple_task import defer

def task1():
    time.sleep(1)
    print("task1 done")

def view1(requests):
    defer(task1)
    return HttpResponse("My View")
# urls.py
from django.contrib import admin
from django.urls import path
from app01 import views

urlpatterns = [
    path('admin/', admin.site.urls),
    path("test", views.view1)
]

No output with example code in Daphne

Thanks for an interesting project! Perhaps I've missed something, but using the current example in the docs doesn't seem to output or execute the deferred functions when using Daphne, but does with Uvicorn.

Using:

  • Python: 3.8.0
  • Django: 3.0.1
  • uvicorn 0.11.1 vs. daphne 2.4.1
  • django-simple-task: 0.1.1

uvicorn's output:

$ uvicorn --log-level debug  background_tasks_test.asgi:application
INFO:     Started server process [33682]
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     127.0.0.1:64302 - "GET /test_tasks/ HTTP/1.1" 200 OK
task1 done
INFO:     [Thread: 4514371008][Worker: 0]: finished task1.
task2 done
INFO:     [Thread: 4514371008][Worker: 0]: finished task2.
…

daphne's output:

$ daphne -v 3 background_tasks_test.asgi:application
2019-12-30 22:33:17,618 INFO     Starting server at tcp:port=8000:interface=127.0.0.1
2019-12-30 22:33:17,618 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2019-12-30 22:33:17,618 INFO     Configuring endpoint tcp:port=8000:interface=127.0.0.1
2019-12-30 22:33:17,619 INFO     HTTPFactory starting on 8000
2019-12-30 22:33:17,619 INFO     Starting factory <daphne.http_protocol.HTTPFactory object at 0x110678c10>
2019-12-30 22:33:17,619 INFO     Listening on TCP address 127.0.0.1:8000
2019-12-30 22:33:25,794 DEBUG    HTTP b'GET' request for ['127.0.0.1', 64312]
2019-12-30 22:33:25,898 WARNING  Executing <Handle callWithLogger(<_GenericHTTP...ol #0 on 8000>, <bound method... 0x110399ac0>>, <_GenericHTTP...ol #0 on 8000>, True) at …/background_tasks_test/virtualenv/lib/python3.8/site-packages/twisted/python/log.py:90 created at /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/selector_events.py:252> took 0.173 seconds
2019-12-30 22:33:26,040 DEBUG    HTTP 200 response started for ['127.0.0.1', 64312]
2019-12-30 22:33:26,040 DEBUG    HTTP close for ['127.0.0.1', 64312]
2019-12-30 22:33:26,040 INFO     "127.0.0.1" - - [01/Jan/1970:00:00:10 +0000] "GET /test_tasks/ HTTP/1.1" 200 7 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"
2019-12-30 22:33:26,041 DEBUG    HTTP response complete for ['127.0.0.1', 64312]
127.0.0.1:64312 - - [30/Dec/2019:22:33:26] "GET /test_tasks/" 200 7
…

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.