mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Webconfig: Run prompts one at a time if necessary
Termux doesn't support sem_open, which means python doesn't support multiprocessing. So we have to resort to brute force. Fixes #7298.
This commit is contained in:
parent
be3a7c03ba
commit
ee84223138
@ -1159,19 +1159,24 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
return None
|
||||
|
||||
def do_get_sample_prompts_list(self):
|
||||
pool = multiprocessing.pool.ThreadPool(processes=8)
|
||||
|
||||
# Kick off the "Current" meta-sample
|
||||
current_metasample_async = pool.apply_async(self.do_get_current_prompt)
|
||||
|
||||
# Read all of the prompts in sample_prompts
|
||||
paths = glob.iglob("sample_prompts/*.fish")
|
||||
sample_results = pool.map(self.read_one_sample_prompt, paths, 1)
|
||||
|
||||
# Finish up
|
||||
result = []
|
||||
result.append(current_metasample_async.get())
|
||||
result.extend([r for r in sample_results if r])
|
||||
try:
|
||||
pool = multiprocessing.pool.ThreadPool(processes=8)
|
||||
|
||||
# Kick off the "Current" meta-sample
|
||||
current_metasample_async = pool.apply_async(self.do_get_current_prompt)
|
||||
|
||||
# Read all of the prompts in sample_prompts
|
||||
sample_results = pool.map(self.read_one_sample_prompt, paths, 1)
|
||||
result.append(current_metasample_async.get())
|
||||
result.extend([r for r in sample_results if r])
|
||||
except ImportError:
|
||||
# If the platform doesn't support multiprocessing, we just do it one at a time.
|
||||
# This happens e.g. on Termux.
|
||||
print("Platform doesn't support multiprocessing, running one at a time. This may take a while.")
|
||||
result.append(self.do_get_current_prompt())
|
||||
result.extend([self.read_one_sample_prompt(path) for path in paths])
|
||||
return result
|
||||
|
||||
def do_get_abbreviations(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user