mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 09:19:23 +01:00
Alternative solution to "get next logits" deadlock (#6106)
This commit is contained in:
parent
9aef01551d
commit
0f3a423de1
@ -16,19 +16,24 @@ def get_next_logits(*args, **kwargs):
|
|||||||
if shared.args.idle_timeout > 0 and shared.model is None and shared.previous_model_name not in [None, 'None']:
|
if shared.args.idle_timeout > 0 and shared.model is None and shared.previous_model_name not in [None, 'None']:
|
||||||
shared.model, shared.tokenizer = load_model(shared.previous_model_name)
|
shared.model, shared.tokenizer = load_model(shared.previous_model_name)
|
||||||
|
|
||||||
shared.generation_lock.acquire()
|
needs_lock = kwargs.get('use_samplers', False)
|
||||||
|
if needs_lock:
|
||||||
|
shared.generation_lock.acquire()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = _get_next_logits(*args, **kwargs)
|
result = _get_next_logits(*args, **kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
models.last_generation_time = time.time()
|
if needs_lock:
|
||||||
shared.generation_lock.release()
|
models.last_generation_time = time.time()
|
||||||
|
shared.generation_lock.release()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _get_next_logits(prompt, state, use_samplers, previous, top_logits=25, return_dict=False):
|
def _get_next_logits(prompt, state, use_samplers=False, previous="", top_logits=25, return_dict=False):
|
||||||
if shared.model is None:
|
if shared.model is None:
|
||||||
logger.error("No model is loaded! Select one in the Model tab.")
|
logger.error("No model is loaded! Select one in the Model tab.")
|
||||||
return 'Error: No model is loaded1 Select one in the Model tab.', previous
|
return 'Error: No model is loaded1 Select one in the Model tab.', previous
|
||||||
|
Loading…
Reference in New Issue
Block a user