Closed mnanao closed 9 months ago
hmm, yeah i have been fighting with tornado here and there. usually i have to clear the kernel/restart python and than it works. there are often some backround loops that dont allow you to run the tornado loop more than once.
i am also quite new to tornado and these io loops, so sorry if i cant help much :)
Cheers, Seb
Am Di., 21. Feb. 2023 um 16:31 Uhr schrieb Max Nanao < @.***>:
Hi, I'm trying to get the critical force script to work on a MacBook Air (M2 Monterey 12.6).
at first there was a problem with the ports,
Traceback (most recent call last): File "/Users/mnanao/PyTindeq-main/laptop/critical_force.py", line 223, in server = Server(apps, port=5000) File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/bokeh/server/server.py", line 429, in init sockets, self._port = bind_sockets(opts.address, opts.port) File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/bokeh/server/util.py", line 68, in bind_sockets ss = netutil.bind_sockets(port=port or 0, address=address) File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/netutil.py", line 162, in bind_sockets sock.bind(sockaddr) OSError: [Errno 48] Address already in use
so I changed the port number. It then got past the binding stage but I have a different error that I can't find much on google about:
python3 critical_force.py *Traceback (most recent call last): File "/Users/mnanao/PyTindeq-main/laptop/critical_force.py", line 228, in tornado.platform.asyncio.AsyncIOMainLoop().install() File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/util.py", line 276, in new instance.initialize(args, **init_kwargs) File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/platform/asyncio.py", line 299, in initialize super().initialize(asyncio.get_event_loop(),
kwargs) File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/platform/asyncio.py", line 136, in initialize raise RuntimeError( RuntimeError: IOLoop <tornado.platform.asyncio.AsyncIOMainLoop object at 0x122aff1c0> already associated with asyncio loop <_UnixSelectorEventLoop running=False closed=False debug=False>
any ideas? Thank you! max
— Reply to this email directly, view it on GitHub https://github.com/StuartLittlefair/PyTindeq/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2E4W3PMGHKTNUMXAWVJMLWYUJY3ANCNFSM6AAAAAAVDOABZM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi @mnanao
I don’t use the macOS version much, so this may be something I need to update - I’ll take a look in the next few days.
In the meantime my initial thoughts is that you might have a stale version of the script running in the background somewhere - or another Python script running in a tornado loop.
I’d look and see if there are any zombie processes if you run a Terminal command like ps -ef | grep python
Hi guys, thanks for the responses! There were no background or zombie processes, but I rebooted just for good measure which did not help. I havent used tornado before either, and haven't found many clues yet as to what the problem could be yet, but am still digging. max
On Tue, Feb 21, 2023 at 10:59 PM StuartLittlefair @.***> wrote:
Hi @mnanao https://github.com/mnanao
I don’t use the macOS version much, so this may be something I need to update - I’ll take a look in the next few days.
In the meantime my initial thoughts is that you might have a stale version of the script running in the background somewhere - or another Python script running in a tornado loop.
I’d look and see if there are any zombie processes if you run a Terminal command like ps -ef | grep python
— Reply to this email directly, view it on GitHub https://github.com/StuartLittlefair/PyTindeq/issues/1#issuecomment-1439143996, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEOSEVDQCSVHW5UTCOELUFTWYU3DFANCNFSM6AAAAAAVDOABZM . You are receiving this because you were mentioned.Message ID: @.***>
OK - I've got to the bottom of this. The Control Center in macOS now reserves port 5000, so it is not available. I've changed the code to listen for commands on the bokeh default port of 5006 in 46732e8ba24ad55880f3a0c83ddd633b5e150963
Grabbing the latest version from GitHub should solve your issues
Thanks for investigating: That fix gets past the Address already in use error, but I still seem to be getting the Tornado/AsyncIO error -- is anyone else seeing it?
Traceback (most recent call last):
File "/Users/mnanao/PyTindeq-main2/laptop/critical_force.py", line 262,
in
tornado.platform.asyncio.AsyncIOMainLoop().install()
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/util.py", line 276, in new
instance.initialize(*args, **init_kwargs)
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/platform/asyncio.py", line 299, in initialize
super().initialize(asyncio.get_event_loop(), **kwargs)
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/platform/asyncio.py", line 136, in initialize
raise RuntimeError(
RuntimeError: IOLoop <tornado.platform.asyncio.AsyncIOMainLoop object at 0x1219401f0> already associated with asyncio loop <_UnixSelectorEventLoop running=False closed=False debug=False>
?
On Fri, Feb 24, 2023 at 2:24 PM StuartLittlefair @.***> wrote:
OK - I've got to the bottom of this. The Control Center in macOS now reserves port 5000, so it is not available. I've changed the code to listen for commands on the bokeh default port of 5006 in 46732e8 https://github.com/StuartLittlefair/PyTindeq/commit/46732e8ba24ad55880f3a0c83ddd633b5e150963
Grabbing the latest version from GitHub should solve your issues
— Reply to this email directly, view it on GitHub https://github.com/StuartLittlefair/PyTindeq/issues/1#issuecomment-1443679490, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEOSEVACEKGGBTDJA3IEU4DWZCZBHANCNFSM6AAAAAAVDOABZM . You are receiving this because you were mentioned.Message ID: @.***>
I’m not seeing that. Can you tell me your python and tornado versions?
Python 3.9.6
bleak==0.19.5
tornado==6.2
bokeh==3.0.3
I went back to the API demo script from tindeq, which threw an error and I believe the issue is caused when another bluetooth LE device responds before the tindeq, and that device does not have a name (name == None). This seems to fix this particular issue:
< if d.name != None:
< if d.name[: len(TARGET_NAME)] == TARGET_NAME:
< address = d.address
< print('Found "{0}" with address {1}'.format(d.name, d.address))
< break
if d.name[: len(TARGET_NAME)] == TARGET_NAME: address = d.address print('Found "{0}" with address {1}'.format(d.name,
d.address))
break
now I am getting some weird encoding issue though!
/Users/mnanao/Library/Python/3.9/lib/python/site-packages/bleak/backends/corebluetooth/client.py:321: UninitializedDeallocWarning: leaking an uninitialized object of type _NSPlaceholderData
value = NSData.alloc().initWithByteslength(data, len(data))
Traceback (most recent call last):
File "/Users/mnanao/Downloads/progressor_client.py", line 225, in
loop.run_until_complete(run(loop, False))
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/Users/mnanao/Downloads/progressor_client.py", line 212, in run
await client.write_gatt_char(CTRL_POINT_CHAR_UUID,
[CMD_GET_BATTERY_VOLTAGE], response=True)
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/bleak/init.py", line 593, in write_gatt_char
await self._backend.write_gatt_char(char_specifier, data, response)
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/bleak/backends/corebluetooth/client.py", line 321, in write_gatt_char
value = NSData.alloc().initWithBytes_length_(data, len(data))
ValueError: depythonifying unknown typespec 0x76
precious little about this particular Bleak error on google :) I suspect it is again some macos weirdness
On Sun, Feb 26, 2023 at 10:04 PM StuartLittlefair @.***> wrote:
I’m not seeing that. Can you tell me your python and tornado versions?
— Reply to this email directly, view it on GitHub https://github.com/StuartLittlefair/PyTindeq/issues/1#issuecomment-1445466933, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEOSEVDNZMYRZNMGEBVMJPDWZPAMDANCNFSM6AAAAAAVDOABZM . You are receiving this because you were mentioned.Message ID: @.***>
With regards to the asyncio error, I've never coded in Python before, however the tornado documentation mentions that tornado.platform.asyncio.AsyncIOMainLoop is deprecated. So I deleted that line of code and updated the Bokeh Div statement from style to styles (looks like change to Bokeh as well) and it seems to now be working.
With regards to the asyncio error, I've never coded in Python before, however the tornado documentation mentions that tornado.platform.asyncio.AsyncIOMainLoop is deprecated. So I deleted that line of code and updated the Bokeh Div statement from style to styles (looks like change to Bokeh as well) and it seems to now be working.
Fantastic - thank you for finding this @akladnig. I don't get as much time to maintain this code as I want at the moment.
Do you want to make a pull request with your changes so you receive proper credit? If not I can make the changes myself.
Hi Stuart,
Please go ahead and make the changes - I'm not up to scratch with GitHub.
Actually there are more breaking updates with Bleak and Bokeh - so maybe wait until I get it working properly and I’ll let you know what I’ve hacked to get it working given that I’m not familiar with Python.
Cheers,
Adrian.
On 5 May 2023, at 8:55 pm, StuartLittlefair @.***> wrote:
With regards to the asyncio error, I've never coded in Python before, however the tornado documentation mentions that tornado.platform.asyncio.AsyncIOMainLoop is deprecated. So I deleted that line of code and updated the Bokeh Div statement from style to styles (looks like change to Bokeh as well) and it seems to now be working.
Fantastic - thank you for finding this @akladnig https://github.com/akladnig. I don't get as much time to maintain this code as I want at the moment.
Do you want to make a pull request with your changes so you receive proper credit? If not I can make the changes myself.
— Reply to this email directly, view it on GitHub https://github.com/StuartLittlefair/PyTindeq/issues/1#issuecomment-1536079117, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2TIKLXHSC6BJWCSHRZTOM3XETMBHANCNFSM6AAAAAAVDOABZM. You are receiving this because you were mentioned.
Hi, I'm trying to get the critical force script to work on a MacBook Air (M2 Monterey 12.6).
at first there was a problem with the ports,
Traceback (most recent call last): File "/Users/mnanao/PyTindeq-main/laptop/critical_force.py", line 223, in
server = Server(apps, port=5000)
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/bokeh/server/server.py", line 429, in init
sockets, self._port = bind_sockets(opts.address, opts.port)
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/bokeh/server/util.py", line 68, in bind_sockets
ss = netutil.bind_sockets(port=port or 0, address=address)
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/netutil.py", line 162, in bind_sockets
sock.bind(sockaddr)
OSError: [Errno 48] Address already in use
so I changed the port number. It then got past the binding stage but I have a different error that I can't find much on google about:
python3 critical_force.py *Traceback (most recent call last): File "/Users/mnanao/PyTindeq-main/laptop/critical_force.py", line 228, in
tornado.platform.asyncio.AsyncIOMainLoop().install()
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/util.py", line 276, in new
instance.initialize( args, init_kwargs)
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/platform/asyncio.py", line 299, in initialize
super().initialize(asyncio.get_event_loop(), kwargs)
File "/Users/mnanao/Library/Python/3.9/lib/python/site-packages/tornado/platform/asyncio.py", line 136, in initialize
raise RuntimeError(
RuntimeError: IOLoop <tornado.platform.asyncio.AsyncIOMainLoop object at 0x122aff1c0> already associated with asyncio loop <_UnixSelectorEventLoop running=False closed=False debug=False>**
any ideas? Thank you! max