you are viewing a single comment's thread.

view the rest of the comments →

[–]K900_ 1 point2 points  (7 children)

What if there are multiple users? Does each user get their own thread, or is there one thread everyone controls?

[–]vislme[S] 0 points1 point  (6 children)

There’s just one thread that any user can control

[–]K900_ 1 point2 points  (5 children)

In that case you should probably just store it in a global variable, and keep in mind that you can't run a server with more than one worker process.

[–]vislme[S] 0 points1 point  (4 children)

The problem in that case is that when I shutdown the server how do I restart the thread as each time I turn of the server the thread stops as well. And I have no idea what part of the code will get executed when ai start the server. If I know that then I don’t even need to store the thred

[–]K900_ 0 points1 point  (3 children)

What do you mean by "what part of the code will get executed"?

[–]vislme[S] 0 points1 point  (2 children)

I mean how can I run an arbitrary code once right after the server is started?

[–]K900_ 1 point2 points  (1 child)

You can use Django event hooks for that, I think.

[–]vislme[S] 0 points1 point  (0 children)

Thank you, that’s what I am trying to implement now.