mirror of
https://github.com/karma-riuk/crab-webapp.git
synced 2025-07-05 06:08:13 +02:00
moved the creation of the thread to the subject
instead of the request handler
This commit is contained in:
@ -99,8 +99,7 @@ def submit_refinement():
|
|||||||
socket2observer[sid] = obs
|
socket2observer[sid] = obs
|
||||||
subject.registerObserver(obs)
|
subject.registerObserver(obs)
|
||||||
|
|
||||||
t = Thread(target=subject.launch_task, args=(validated,), daemon=True)
|
subject.launch_task(validated)
|
||||||
t.start()
|
|
||||||
url = url_for(f".status", id=process_id, _external=True)
|
url = url_for(f".status", id=process_id, _external=True)
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Callable, Optional, Set, Any
|
from threading import Thread
|
||||||
|
from typing import Callable, Iterable, Mapping, Optional, Set, Any
|
||||||
|
|
||||||
|
|
||||||
class Status(Enum):
|
class Status(Enum):
|
||||||
@ -61,9 +62,17 @@ class Subject:
|
|||||||
|
|
||||||
def launch_task(self, *args, **kwargs):
|
def launch_task(self, *args, **kwargs):
|
||||||
self.status = Status.PROCESSING
|
self.status = Status.PROCESSING
|
||||||
self.task(
|
t = Thread(
|
||||||
*args, **kwargs, percent_cb=self.notifyPercentage, complete_cb=self.notifyComplete
|
target=self.task,
|
||||||
|
args=args,
|
||||||
|
kwargs={
|
||||||
|
**kwargs,
|
||||||
|
"percent_cb": self.notifyPercentage,
|
||||||
|
"complete_cb": self.notifyComplete,
|
||||||
|
},
|
||||||
|
daemon=True,
|
||||||
)
|
)
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
|
||||||
request2status: dict[str, Subject] = {}
|
request2status: dict[str, Subject] = {}
|
||||||
|
Reference in New Issue
Block a user