optionchainstream icon indicating copy to clipboard operation
optionchainstream copied to clipboard

TypeError: cannot pickle '_thread.lock' object

Open usr1smcpl opened this issue 4 years ago • 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

usr1smcpl avatar May 21 '21 02:05 usr1smcpl

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?

ranjanrak avatar May 21 '21 04:05 ranjanrak

The OS is Windows 10 Python is Python 3.8.5

usr1smcpl avatar May 21 '21 04:05 usr1smcpl

Yes. We are facing the same issue too.

sriraj1122 avatar May 25 '21 06:05 sriraj1122

But we actually fixed the issue in Windows. Let us know if you want the code.

sriraj1122 avatar May 25 '21 06:05 sriraj1122

@sriraj1122 definitely kindly provide the code. Many thanks in advance. Regards

usr1smcpl avatar May 25 '21 07:05 usr1smcpl

@sriraj1122 I wasn't able to check this on Window O.S. Can you create PR for this? Will help others as well. Thanks

ranjanrak avatar May 25 '21 13:05 ranjanrak

@sriraj1122 is it possible to share the code that works on windows/address the pickle'thread' issue? Thanks

usr1smcpl avatar Jun 15 '21 02:06 usr1smcpl

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.

mohitgupta1918 avatar Sep 09 '21 16:09 mohitgupta1918

@ranjanrak It seems the issue is still present. I have tried in macos.

revanthgss avatar Feb 28 '22 17:02 revanthgss

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']}

njLabs avatar Mar 26 '24 06:03 njLabs