-
-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with silk in child threads #169
Comments
I have the same issue! Is there any way to temporarily store the request context information that Silk needs? |
Having the identical problem. Looking forward to finding some kind of solution... |
Just getting started with silk. Just run across this. The problem seems to be with a thread local on the DataCollector class, which is a Singleton. When a thread other than the first one tries to create a DataCollector it will retrieve the already initialised object, but as that object uses thread locals internally it is actually uninitialised (other than the first thread that created it). |
@rubendura Thanks for the updated information on furthering the problem space for potential solution. |
We are having the same issue |
We are also having the same issue. Any update on this? |
Same issue, any update on this??? getting this when using |
Same issue. Any recommended way to dynamically disable the middleware (i.e. when we are using threads)? |
I'm running into this exact problem. I'm running a SQL query in a thread after a request finishes for aggregation purposes. Is there a way I can disable silk for a thread? |
Same issue. Using with django-channels. |
Same issue.I add DataCollector().configure() to my function and this error never show up. I don't know if there are any other problems. |
I have seen the similar issue, and it turned out to be a threading related issue. My idea is to have a DataCollector class specific singleton implementation, in addition to the check of existence of instance itself, check also if this thread local info is lost. If this thread specific info is lost, it indicates a thread switch, then the data collector needs to be re-instantiated. Otherwise, it is wiser to implement a threading aware singleton. That is to say, the singleton parent class will keep a mapping between the thread instance and its singleton instance, if thread context changes, the singleton instance needs to be changed as well. |
It seems that commit f7fd730 has improved the situation... I have spent time to reproduce this error in the simplest way, using the input from @rubendura and @pptime. I forked django-silk and added a view
Using the dev server, I would expect that a request to
and indeed... the MiddleWare error appeared again:
Hope this helps ... |
Hi,
I'm working on synchronous API that is processing some data. In order to speed things up I have decided to spawn multiple threads in Django request and do processing there. The problem occurs when one of the threads tries to execute sql queries. Is there any way to run silk and spawn child threads?
The
self.register_objects(TYP_QUERIES, *args)
could just give a warning in that case and carry on.Thanks,
Marcin
The text was updated successfully, but these errors were encountered: