Spaces:
Runtime error
Runtime error
better wait and trace for concurrent futures
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import functools
|
|
3 |
import logging
|
4 |
import os
|
5 |
import re
|
|
|
6 |
import uuid
|
7 |
import datetime
|
8 |
from time import sleep
|
@@ -131,6 +132,13 @@ def chat(history1, history2, system_msg):
|
|
131 |
futures.append(executor.submit(model_hermes, messages1))
|
132 |
futures.append(executor.submit(model_manticore, messages2))
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
tokens_hermes = re.findall(r'\s*\S+\s*', futures[0].result()[0]['generated_text'])
|
135 |
tokens_manticore = re.findall(r'\s*\S+\s*', futures[1].result()[0]['generated_text'])
|
136 |
len_tokens_hermes = len(tokens_hermes)
|
|
|
3 |
import logging
|
4 |
import os
|
5 |
import re
|
6 |
+
import traceback
|
7 |
import uuid
|
8 |
import datetime
|
9 |
from time import sleep
|
|
|
132 |
futures.append(executor.submit(model_hermes, messages1))
|
133 |
futures.append(executor.submit(model_manticore, messages2))
|
134 |
|
135 |
+
# Wait for all threads to finish...
|
136 |
+
for future in concurrent.futures.as_completed(futures):
|
137 |
+
# If desired, you can check for exceptions here...
|
138 |
+
if future.exception() is not None:
|
139 |
+
print('Exception: {}'.format(future.exception()))
|
140 |
+
traceback.print_exception(type(future.exception()), future.exception(), future.exception().__traceback__)
|
141 |
+
|
142 |
tokens_hermes = re.findall(r'\s*\S+\s*', futures[0].result()[0]['generated_text'])
|
143 |
tokens_manticore = re.findall(r'\s*\S+\s*', futures[1].result()[0]['generated_text'])
|
144 |
len_tokens_hermes = len(tokens_hermes)
|