efinance icon indicating copy to clipboard operation
efinance copied to clipboard

多股票获取报错

Open jasonhuizhang opened this issue 2 years ago • 7 comments

Processing => 300355: 1%|▏ | 69/4714 [00:15<13:53, 5.57it/s]Traceback (most recent call last): File "/Users/zhanghui/Documents/Program/实时获取行情efinance-main/test.py", line 35, in st = ef.stock.get_quote_history(code) File "/Users/zhanghui/Documents/Program/实时获取行情efinance-main/efinance/stock/getter.py", line 246, in get_quote_history fqt=fqt File "/Users/zhanghui/Documents/Program/实时获取行情efinance-main/efinance/common/getter.py", line 207, in get_quote_history Processing => 600091: 1%|▏ | 70/4714 [00:16<20:29, 3.78it/s] **kwargs) File "/Users/zhanghui/Documents/Program/实时获取行情efinance-main/efinance/common/getter.py", line 140, in get_quote_history_multi start(code) File "/opt/anaconda3/lib/python3.7/site-packages/multitasking/init.py", line 119, in async_method Processing => 300386: 2%|▏ | 71/4714 [00:16<19:00, 4.07it/s] File "/opt/anaconda3/lib/python3.7/threading.py", line 852, in start _start_new_thread(self._bootstrap, ()) RuntimeError: can't start new thread

这个是不是我电脑不行,所以停止了多线程?

jasonhuizhang avatar May 17 '22 01:05 jasonhuizhang

限制一下线程数量吧。代码如下

import multitasking
multitasking.set_max_threads(8)

把上面的代码放在前面,然后再获取数据。

Micro-sheep avatar May 17 '22 01:05 Micro-sheep

multitasking.set_max_threads(2) st = ef.stock.get_quote_history(code) 这样吗? 我这样写还是出现 RuntimeError: can't start new thread

jasonhuizhang avatar May 17 '22 03:05 jasonhuizhang

multitasking.set_max_threads(2)

st = ef.stock.get_quote_history(code)

这样吗?

我这样写还是出现 RuntimeError: can't start new thread

对,是这样子写。你再试一下,把代码写到 .py 文件里面再运行 .py 文件。

Micro-sheep avatar May 17 '22 03:05 Micro-sheep

不行,还是这个错误

jasonhuizhang avatar May 17 '22 03:05 jasonhuizhang

不行,还是这个错误

那暂时没有办法了,我没有 mac 来测试。你先用单线程的吧,每次传一只股票代码。或者也可以自己想想怎么加多线程。

Micro-sheep avatar May 17 '22 03:05 Micro-sheep

好的,谢谢

jasonhuizhang avatar May 17 '22 04:05 jasonhuizhang

还真是Mac和win的系统问题。用win完全没问题

jasonhuizhang avatar May 18 '22 05:05 jasonhuizhang