Skip to content

Windows 10 - RuntimeError: Event loop is closed and UnicodeEncodeError: 'charmap' codec can't encode character #3

@pybokeh

Description

@pybokeh

Not a bug, but perhaps it should be mentioned that databay will not work with Windows 10 due to a bug or the way asyncio chooses the default event loop mechanism, which throws an error, instead of just a warning.

So if running asyncio-dependent code on Windows machine, you will get an error similar below:

Traceback (most recent call last):
  File "C:\Programs\Python38\lib\asyncio\proactor_events.py", line 95, in __del__
    self.close()
  File "C:\Programs\Python38\lib\asyncio\proactor_events.py", line 86, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Programs\Python38\lib\asyncio\base_events.py", line 683, in call_soon
    self._check_closed()
  File "C:\Programs\Python38\lib\asyncio\base_events.py", line 475, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Per this SO question, possible workaround is to use asyncio loop's run_until_complete() instead of just run()


(Update 1 by Voy - added more info)

To Reproduce
Example code (blockchain example):

import datetime

from databay.inlets import HttpInlet
from databay.outlets import PrintOutlet
from databay import Link
from databay.planners import APSPlanner

stock_inlet = HttpInlet('https://blockchain.info/ticker')

print_outlet = PrintOutlet(True, True)

link = Link(stock_inlet, print_outlet, interval=datetime.timedelta(seconds=1))

planner = APSPlanner(link)

planner.start()

Environment
Databay version: 0.1.2
Python version: 3.8.2
OS: Ubuntu 20.04 and Windows 10


(Update 2 by Voy - explaining the true issue)

The RuntimeError: Event loop is closed is only half of the problem here, and in fact is not the cause for the code to stop working, but a side effect happening when program terminates and can be fixed easily. The code wouldn't execute due to UnicodeEncodeError, which we figure out later down the line.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions