TypeError: cannot pickle '_thread.lock' object
usr1smcpl opened this issue · 10 comments
Hi,
I tried to upgrade the python package and run v0.5, but again it's showing the following error:
TypeError Traceback (most recent call last)
in
10 # Stream option chain data in real-time
11 StreamData = OptionStream.create_option_chain()
---> 12 for data in StreamData:
13 print(data)
~\anaconda3\lib\site-packages\optionchain_stream\option_chain.py in create_option_chain(self)
30 self.socketClient = WebsocketClient(self.api_key, self.api_secret, self.request_token, self.symbol, self.expiry)
31 # create streaming websocket data
---> 32 self.socketClient.queue_callBacks()
33 # Keep fetching streaming Queue
34 while 1:
~\anaconda3\lib\site-packages\optionchain_stream\websocket.py in queue_callBacks(self)
92 """
93 # Process to keep updating real time tick to DB
---> 94 Process(target=self.assign_callBacks,).start()
95 # Delay to let intial instrument DB sync
96 # For option chain to fetch value
~\anaconda3\lib\multiprocessing\process.py in start(self)
119 'daemonic processes are not allowed to have children'
120 _cleanup()
--> 121 self._popen = self._Popen(self)
122 self._sentinel = self._popen.sentinel
123 # Avoid a refcycle if the target function holds an indirect
~\anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
222 @staticmethod
223 def _Popen(process_obj):
--> 224 return _default_context.get_context().Process._Popen(process_obj)
225
226 class DefaultContext(BaseContext):
~\anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
325 def _Popen(process_obj):
326 from .popen_spawn_win32 import Popen
--> 327 return Popen(process_obj)
328
329 class SpawnContext(BaseContext):
~\anaconda3\lib\multiprocessing\popen_spawn_win32.py in init(self, process_obj)
91 try:
92 reduction.dump(prep_data, to_child)
---> 93 reduction.dump(process_obj, to_child)
94 finally:
95 set_spawning_popen(None)
~\anaconda3\lib\multiprocessing\reduction.py in dump(obj, file, protocol)
58 def dump(obj, file, protocol=None):
59 '''Replacement for pickle.dump() using ForkingPickler.'''
---> 60 ForkingPickler(file, protocol).dump(obj)
61
62 #
TypeError: cannot pickle '_thread.lock' object
Kindly let us know what could be the issue?
Thanks in advance
I'm not able to reproduce the above pickle issue in my below setup:
O.S="Ubuntu"
O.S VERSION="18.04.3 LTS (Bionic Beaver)"
Python 3.6.9
Can you let me know your OS and Python version details?
The OS is Windows 10
Python is Python 3.8.5
Yes. We are facing the same issue too.
But we actually fixed the issue in Windows. Let us know if you want the code.
@sriraj1122 definitely kindly provide the code.
Many thanks in advance. Regards
@sriraj1122
I wasn't able to check this on Window O.S.
Can you create PR for this? Will help others as well.
Thanks
@sriraj1122 is it possible to share the code that works on windows/address the pickle'thread' issue? Thanks
But we actually fixed the issue in Windows. Let us know if you want the code.
would be helpful if you could post the code here or create a PR.
@ranjanrak It seems the issue is still present. I have tried in macos.
you need to remove the volume key from the below code in on_ticks.
optionData = {'token':tick['instrument_token'], 'symbol':contract_detail['symbol'],
'last_price':tick['last_price'], 'change':tick['change'],
'oi':tick['oi']}