You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why it is not working by just replacing ThreadPoolExecutor with ProcessPoolExecutor? @FraBle Can you please look at this and reply as soon as possible? Thank you.
Here is a code snippet using your code:
importosimportjsonfromsutimeimportSUTimefromconcurrent.futuresimportProcessPoolExecutorfrommultiprocessingimportcpu_countdefget_sutime():
jar_files=os.path.join(os.path.dirname(__file__), os.pardir, "jars")
sutime=SUTime(jars=jar_files, mark_time_ranges=True)
returnsutimedefstruct_filing(sentence, sutime):
returnsentence, sutime.parse(sentence)
defget_time(text_list):
sutime=get_sutime()
withProcessPoolExecutor(max_workers=cpu_count()) asexecutor:
returndict(
future.result()
forfuturein [
executor.submit(struct_filing, sentence, sutime)
forsentenceintext_list
]
)
if__name__=="__main__":
data_set_1= {
"The Formula One race came to Singapore in 2008.",
"It was a tremendous success and gained wide international coverage.",
"In a first for the F1, the event was held at night.",
"State-of-the-art technology was used to ensure that the race operated"" in near daylight conditions.",
"Holding the race at night had a great advantage as European audiences"" could watch it at a convenient time.",
"Over the years, Singapore’s tourism industry has gained significant"" benefits from the media attention that the race has generated",
}
print(json.dumps(get_time(data_set_1), sort_keys=True, indent=4))
Activity