Coder Social home page Coder Social logo

django-after-response's People

Contributors

defrex avatar itamarhaber 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

django-after-response's Issues

This project is not thread safe

The function_queue variable is shared between all the threads on a process. If thread 1 adds something to the queue and then does some more processing and thread 2 comes along and finishes, even if it didn't add anything to the queue, it will process thread 1's function while thread 1 is still running.

You should replace function queue with a method that will pull the list from the threading.local and create it if it does not exist. Do not just put the variable in threading.local and leave it as a global variable. Then you'll just be sharing the thread local with all the other processes.

It should be something like this:

import threading
threadlocal = threading.local()    

def function_queue():
  queue = getattr(threadlocal, 'function_queue', None)
  if v is None:
    queue = []
    setattr(threadlocal, 'function_queue', queue)
  return queue

No love for Python 3?

python --version
    Python 3.4.2

    from decorators import *
ImportError: No module named 'decorators'

Logger Problem

I don't know how exactly this error occurs, but in my case i get the following error:

No handlers could be found for logger "after_response.signals"

More disturbing however is the fact that the database update I placed within the decorated function doesn't happen either.
I understand the function isn't getting executed but I have no idea why.
Any idea why this is happening?

I'm running django version 1.11.13 on Python 2.7.

Latest version not found on pypi?

$ pip install django-after-response==0.2.2
Collecting django-after-response==0.2.2
  Could not find a version that satisfies the requirement django-after-response==0.2.2 (from versions: 0.1.0, 0.1.1, 0.2.0, 0.2.1)
  No distributions matching the version for django-after-response==0.2.2

I had to install from git to get 0.2.2:

$ pip install git+git://github.com/defrex/django-after-response@98e00c766b5160b529a4ef810412eb9d2e6fc9a3

Magic ... wow ... but how?

For me this is magic. I have no clue how I can execute code after the http response was sent to the client with django.

Could you please elaborate the README and explain how the magic works.

This would be very kind.

Regards,
Thomas Güttler

provide a way to disable threads in tests

Hello,

Starting at version 0.2.0 I have many test fails because my tests expect synchronous execution of after-response callbacks.

I could add timers, but I think synchronous tests are more reliable.

Celery provides a CELERY_ALWAYS_EAGER option to disable asynchronous calls. Could you add something similar ?

Thank you,
Julien

how to import a model into "after response"?

I need to import a model into the after response, but I can not.

import after_response

@after_response.enable
def example():
from automacao.models import Automacao
Automacao.objects.count()
...

{ProgrammingError}relation "automacao" does not exist
LINE 1: SELECT COUNT(*) FROM "automacao" WHERE "automacao"."is_delet...

Adaptation for progress bar?

Hey there

Is there any way this could be adapted to create a progress bar?

for example, if one were to have a large function running, after_response would send a value out for jquery or ajax call to ingest at every iteration of a loop?

Cheers

Cannot use @override_settings

Because the setting is loaded to local variable, these test decodators do not work. I do not any problem to load the setting from the settings every time?

Now I have to import those and them override it manyally like: signals.AFTER_RESPONSE_RUN_ASYNC = False

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.