Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: cannot pickle '_thread.lock' object #5

Open
usr1smcpl opened this issue May 21, 2021 · 10 comments
Open

TypeError: cannot pickle '_thread.lock' object #5

usr1smcpl opened this issue May 21, 2021 · 10 comments

Comments

@usr1smcpl
Copy link

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

@ranjanrak
Copy link
Owner

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?

@usr1smcpl
Copy link
Author

The OS is Windows 10
Python is Python 3.8.5

@sriraj1122
Copy link

Yes. We are facing the same issue too.

@sriraj1122
Copy link

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

@usr1smcpl
Copy link
Author

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

@ranjanrak
Copy link
Owner

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

@usr1smcpl
Copy link
Author

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

@mohitgupta1918
Copy link

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.

@revanthgss
Copy link

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

@njLabs
Copy link

njLabs commented Mar 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants