Python Forum
Error: There is no current event loop in thread 'MainThread'
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error: There is no current event loop in thread 'MainThread'
#1
Exclamation 
Python 3.7.2

In my processing, the main function is wrapped by error interceptors and the interception is performed correctly:
try:
    downloader = Downloader.Downloader()
    downloader.download()
except Exception as err:
    General.exist_error = True
    Events.Sender.send_error(err)
But if an error occurred (and was correctly intercepted!), then the following start of processing fall down on the line:
self.event_exist_data = Event()
with error:
Error:
There is no current event loop in thread 'MainThread'
I found the place of the code in which the error occurs (module events):
class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
...
    def get_event_loop(self):
        """Get the event loop.

        This may be None or an instance of EventLoop.
        """
        if (self._local._loop is None and #TRUE
                not self._local._set_called and #FALSE BECAUSE self._local._set_called IS TRUE !!!
                isinstance(threading.current_thread(), threading._MainThread)): #TRUE
            self.set_event_loop(self.new_event_loop())

        if self._local._loop is None:
            raise RuntimeError('There is no current event loop in thread %r.' #On the second, third ... iteration I get here!!!
                               % threading.current_thread().name)

        return self._local._loop
Reply


Messages In This Thread
Error: There is no current event loop in thread 'MainThread' - by AlekseyPython - Feb-18-2019, 10:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error: can't start new thread maha2 0 1,580 Jun-13-2023, 12:26 PM
Last Post: maha2
  help RuntimeError: no running event loop marpaslight 5 3,982 Oct-18-2022, 10:04 PM
Last Post: marpaslight
  A question about 'Event loop is closed' fc5igm 2 2,359 Oct-05-2021, 02:00 AM
Last Post: fc5igm
  bleak library RuntimeError: This event loop is already running alice93 3 4,251 Sep-30-2021, 08:06 AM
Last Post: alice93
  Pool multiprocessing - know current status in loop? korenron 0 1,680 Jul-28-2021, 08:49 AM
Last Post: korenron
  RuntimeError: This event loop is already running newbie2019 2 7,039 Sep-30-2020, 06:59 PM
Last Post: forest44
  Cant find root cause of thread.lock error burlyboys 0 1,590 May-18-2020, 12:51 PM
Last Post: burlyboys
  Error SQLite objects created in a thread can only be used in that same thread. binhduonggttn 3 15,817 Jan-31-2020, 11:08 AM
Last Post: DeaD_EyE
  Com Error with macro within for loop due to creating new workbook in the loop Lastwizzle 0 1,402 May-18-2019, 09:29 PM
Last Post: Lastwizzle
  How to add coroutine to a running event loop? AlekseyPython 1 8,299 Mar-21-2019, 06:04 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020