Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

simpleSystemBase logging OK, any multiprocessing base logging config fails

See original GitHub issue

Logging and logging config work fine with the simpleSystemBase. I neglected to do initial testing of logging with any multi-processing base and have enough code written now that I am a bit lost as to why logging config fails with these bases. To be honest, I am new to Thespian and don’t really understand what I have to do (besides providing the config parameters) to get logging correctly configured for the multi-processing case.

These error messages are produced whenever an Actor is created. How can I resolve these config issues?

ERROR ActorAddr-(T|:63818) => Actor core.app_manager.AppManager @ ActorAddr-(T|:63818) instantiation exception Traceback (most recent call last): File “C:\Program Files\Python38\lib\logging\”, line 642, in configure self.configure_root(root) File “C:\Program Files\Python38\lib\logging\”, line 802, in configure_root self.common_logger_config(root, config, incremental) File “C:\Program Files\Python38\lib\logging\”, line 783, in common_logger_config logger.removeHandler(h) File “C:\Users\xxxx\.virtualenvs\ML_GUI\lib\site-packages\thespian\system\”, line 187, in removeHandler raise NotImplementedError(‘Cannot add logging handlers for Thespian Actors’) NotImplementedError: Cannot add logging handlers for Thespian Actors

The above exception was the direct cause of the following exception: Traceback (most recent call last): File “C:\Users\xxxx\.virtualenvs\ML_GUI\lib\site-packages\thespian\system\”, line 62, in _createInstance actorInst = withPossibleInitArgs(capabilities=self.capabilities, File “C:\Users\xxxx\.virtualenvs\ML_GUI\lib\site-packages\thespian\system\”, line 334, in create return klass(**{ k: self.kwargs[k] for k in initsig if k in self.kwargs }) File “D:\Projects\InfoEdgeV2\InfoEdge\core\”, line 21, in init self.asys = ActorSystem(ACTOR_SYSTEM_BASE) File “C:\Users\xxxx\.virtualenvs\ML_GUI\lib\site-packages\thespian\”, line 637, in init systemBase = self._startupActorSys( File “C:\Users\xxxx\.virtualenvs\ML_GUI\lib\site-packages\thespian\”, line 662, in _startupActorSys systemBase = thespian.system
File “C:\Users\xxxx\.virtualenvs\ML_GUI\lib\site-packages\thespian\system\”, line 257, in init if logDefs is not False: dictConfig(logDefs or defaultLoggingConfig) File “C:\Program Files\Python38\lib\logging\”, line 808, in dictConfig dictConfigClass(config).configure() File “C:\Program Files\Python38\lib\logging\”, line 644, in configure raise ValueError('Unable to configure root ’ ValueError: Unable to configure root logger

Config used (copied from example code):

class actorLogFilter(logging.Filter):
    def filter(self, logrecord):
        return 'actorAddress' in logrecord.__dict__
class notActorLogFilter(logging.Filter):
    def filter(self, logrecord):
        return 'actorAddress' not in logrecord.__dict__
logcfg = { 'version': 1,
           'formatters': {
               'normal': {'format': '%(levelname)-8s %(message)s'},
               'actor': {'format': '%(levelname)-8s %(actorAddress)s => %(message)s'}},
           'filters': { 'isActorLog': { '()': actorLogFilter},
                        'notActorLog': { '()': notActorLogFilter}},
           'handlers': { 'h1': {'class': 'logging.FileHandler',
                                'filename': 'InfoEdge.log',
                                'formatter': 'normal',
                                'filters': ['notActorLog'],
                                'level': logging.INFO},
                         'h2': {'class': 'logging.FileHandler',
                                'filename': 'InfoEdge.log',
                                'formatter': 'actor',
                                'filters': ['isActorLog'],
                                'level': logging.INFO},},
           'loggers' : { '': {'handlers': ['h1', 'h2'], 'level': logging.DEBUG}}


    asys = ActorSystem(ACTOR_SYSTEM_BASE, logDefs=logcfg)    
    # Fails on actor creation ...
    app_mg_addr = asys.createActor(AppManager, globalName=APP_MANAGER_NAME)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

barfarklecommented, Feb 2, 2021

I think you may have found my bug - I was going for latter approach - Qt accessing the Actor system as an external entity and running in the context of the main thread - but appear to have screwed up the implementation details. Will correct and see if cleaner separation fixes the issue. Thanks a lot for your help!

kquickcommented, Feb 2, 2021

I don’t have a lot of experience with Python Qt bindings, but I suspect you are going to encounter some difficulties trying to run Qt from within Actors because Qt probably has internal event loops designed to manage the various keyboard, mouse, and screen operations. If that turns out to be t he case, you may be able to achieve it with a single Actor managing all of the Qt activities or with the Actor system handling all non-GUI operations and the Qt managed in the main application.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How should I log while using multiprocessing in Python?
I just now wrote a log handler of my own that just feeds everything to the parent process via a pipe. I've only...
Read more >
Picamera2 failed to turn on while using python multiprocessing
Maybe you could start by logging all the calls to Picamera2 and then creating the simplest script possible that shows the problem?
Read more >
Multiprocessing Logging in Python
Logging is achieved by first configuring the log handler and then adding calls to the logging infrastructure at key points in the program....
Read more >
multiprocessing — Process-based parallelism — Python 3.11 ...
This basic example of data parallelism using Pool ,. from multiprocessing import Pool ... All resources of the parent are inherited by the...
Read more >
Why your multiprocessing Pool is stuck (it's full of sharks!)
On Linux, the default configuration of Python's multiprocessing library ... logging.error("hello, I did something") print("...logged") if ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found