for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import asyncio
import logging
from cached_property import cached_property
from .dispatcher import LoaferDispatcher
This can be caused by one of the following:
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
# .scrutinizer.yml before_commands: - sudo pip install abc # Python2 - sudo pip3 install abc # Python3
This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.
__init__.py
from .runners import LoaferRunner
logger = logging.getLogger(__name__)
class LoaferManager:
def __init__(self, routes, consumers, runner=None):
self.runner = runner or LoaferRunner(on_stop_callback=self.on_loop__stop)
self.routes = routes
self.consumers = consumers
@cached_property
def dispatcher(self):
return LoaferDispatcher(self.routes, self.consumers)
def run(self, forever=True):
self._future = asyncio.gather(self.dispatcher.dispatch_providers())
_future
__init__
It is generally a good practice to initialize all attributes to default values in the __init__ method:
class Foo: def __init__(self, x=None): self.x = x
self._future.add_done_callback(self.on_future__errors)
self.runner.start(self._future, run_forever=forever)
#
# Callbacks
def on_future__errors(self, future):
exc = future.exception()
# Unhandled errors crashes the event loop execution
if isinstance(exc, BaseException):
logger.critical('Fatal error caught: {!r}'.format(exc))
self.runner.stop()
def on_loop__stop(self, *args, **kwargs):
args
kwargs
logger.debug('Stopping consumers ...')
self.dispatcher.stop_providers()
if hasattr(self, '_future'):
logger.debug('Cancel schedulled operations ...')
self._future.cancel()
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.