cleanup
This commit is contained in:
parent
2ed0e01db6
commit
7998cfca87
|
@ -20,7 +20,7 @@ STREAM_NAME_PREFIX = 'stream'
|
||||||
def check_cancellation(event, event_id):
|
def check_cancellation(event, event_id):
|
||||||
"""
|
"""
|
||||||
This thread checks the pub/sub channel in the background so the main process
|
This thread checks the pub/sub channel in the background so the main process
|
||||||
isn't bogged down with Redis calls.
|
isn't bogged down with Redis calls. Otherwise, the main process slows down to 1 token/sec.
|
||||||
:param event:
|
:param event:
|
||||||
:param event_id:
|
:param event_id:
|
||||||
:return:
|
:return:
|
||||||
|
@ -43,8 +43,7 @@ def inference_do_stream(stream_name: str, msg_to_backend: dict, backend_url: str
|
||||||
stream_name = get_stream_name(stream_name)
|
stream_name = get_stream_name(stream_name)
|
||||||
stream_redis.delete(get_stream_name(stream_name)) # be extra sure
|
stream_redis.delete(get_stream_name(stream_name)) # be extra sure
|
||||||
event = threading.Event()
|
event = threading.Event()
|
||||||
t = threading.Thread(target=check_cancellation, args=(event, event_id))
|
threading.Thread(target=check_cancellation, args=(event, event_id)).start()
|
||||||
t.start()
|
|
||||||
try:
|
try:
|
||||||
response = generator(msg_to_backend, backend_url)
|
response = generator(msg_to_backend, backend_url)
|
||||||
generated_text = ''
|
generated_text = ''
|
||||||
|
|
Loading…
Reference in New Issue