How to use service runner in nameko? - python

As written in nameko's document, I run this example and it works:
from nameko.runners import ServiceRunner
from nameko.testing.utils import get_container
from nameko.rpc import rpc
class ServiceA:
name = "service_a"
class ServiceB:
name = "service_b"
# create a runner for ServiceA and ServiceB
runner = ServiceRunner(config={})
runner.add_service(ServiceA)
runner.add_service(ServiceB)
# ``get_container`` will return the container for a particular service
container_a = get_container(runner, ServiceA)
# start both services
runner.start()
print('runner start')
# stop both services
runner.stop()
It shows:
runner start
but when i add a rpc method in service_a, and add a AMQP_URI in config, it doesn't work, looks like it doesn't connected to RabbitMQ. What should i do?
class ServiceA:
name = "service_a"
#rpc
def hello_a(self):
return 'hello service_a.'
config = {
'AMQP_URI': 'amqp://guest:guest#localhost',
}
runner = ServiceRunner(config=config)
when i press Ctrl+C:
Traceback (most recent call last):
File "/Users/apple/Documents/nameko_test/proxy.py", line 34, in <module>
runner.start()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/nameko/runners.py", line 65, in start
SpawningProxy(self.containers).start()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/nameko/utils/__init__.py", line 181, in spawning_method
return list(pool.imap(call, self._items))
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/greenpool.py", line 244, in next
val = self.waiters.get().wait()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/greenthread.py", line 179, in wait
return self._exit_event.wait()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/event.py", line 121, in wait
return hubs.get_hub().switch()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/hubs/hub.py", line 295, in switch
return self.greenlet.switch()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/hubs/hub.py", line 337, in run
self.fire_timers(self.clock())
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/hubs/hub.py", line 458, in fire_timers
timer()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/hubs/timer.py", line 58, in __call__
cb(*args, **kw)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/greenthread.py", line 221, in main
self._resolve_links()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/greenthread.py", line 236, in _resolve_links
f(self, *ca, **ckw)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/nameko/containers.py", line 458, in _handle_managed_thread_exited
self._handle_thread_exited(gt)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/nameko/containers.py", line 462, in _handle_thread_exited
gt.wait()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/greenthread.py", line 179, in wait
return self._exit_event.wait()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/event.py", line 125, in wait
current.throw(*self._exc)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/eventlet/greenthread.py", line 218, in main
result = function(*args, **kwargs)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/kombu/mixins.py", line 177, in run
for _ in self.consume(limit=None): # pragma: no cover
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/kombu/mixins.py", line 199, in consume
conn.drain_events(timeout=safety_interval)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/kombu/connection.py", line 288, in drain_events
return self.transport.drain_events(self.connection, **kwargs)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/kombu/transport/pyamqp.py", line 95, in drain_events
return connection.drain_events(**kwargs)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/amqp/connection.py", line 303, in drain_events
chanmap, None, timeout=timeout,
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/amqp/connection.py", line 366, in _wait_multiple
channel, method_sig, args, content = read_timeout(timeout)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/amqp/connection.py", line 337, in read_timeout
return self.method_reader.read_method()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/amqp/method_framing.py", line 186, in read_method
self._next_method()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/amqp/method_framing.py", line 107, in _next_method
frame_type, channel, payload = read_frame()
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/amqp/transport.py", line 154, in read_frame
frame_header = read(7, True)
File "/Users/apple/Documents/my_projects/venv/lib/python3.6/site-packages/amqp/transport.py", line 277, in _read
s = recv(n - len(rbuf))
KeyboardInterrupt

I suspect you are missing import eventlet; eventlet.monkey_patch() at the top of your file. Eventlet is mentioned in the documentation but I think it could be clearer, and possibly explicitly added to some of the examples.
Alternatively you could use the bundled service runner (which handles this for you) by making a module with just your service definitions and using nameko run from the command line like in the hello world example

Related

How to resolve the Error in anaconda start up?

Few days ago, Anaconda Navigator used to work fine but now it won't open; I've even reinstalled the navigator but still getting the same issue.
Here is the error message
Navigator Error:
An unexpected error occurred on Navigator start-up
Main Error
unacceptable character #x0000: special characters are not allowed
in "C:\Users\home\.continuum\anaconda-client\config.yaml", position 0
Traceback
Traceback (most recent call last):
File "C:\Users\home\anaconda3\lib\site-packages\anaconda_navigator\exceptions.py", line 72, in exception_handler
return_value = func(*args, **kwargs)
File "C:\Users\home\anaconda3\lib\site-packages\anaconda_navigator\app\start.py", line 146, in start_app
window = run_app(splash)
File "C:\Users\home\anaconda3\lib\site-packages\anaconda_navigator\app\start.py", line 65, in run_app
window = MainWindow(splash=splash)
File "C:\Users\home\anaconda3\lib\site-packages\anaconda_navigator\widgets\main_window.py", line 165, in __init__
self.api = AnacondaAPI()
File "C:\Users\home\anaconda3\lib\site-packages\anaconda_navigator\api\anaconda_api.py", line 1518, in AnacondaAPI
ANACONDA_API = _AnacondaAPI()
File "C:\Users\home\anaconda3\lib\site-packages\anaconda_navigator\api\anaconda_api.py", line 83, in __init__
self._client_api = ClientAPI(config=self.config)
File "C:\Users\home\anaconda3\lib\site-packages\anaconda_navigator\api\client_api.py", line 659, in ClientAPI
CLIENT_API = _ClientAPI(config=config)
File "C:\Users\home\anaconda3\lib\site-packages\anaconda_navigator\api\client_api.py", line 95, in __init__
self.reload_client()
File "C:\Users\home\anaconda3\lib\site-packages\anaconda_navigator\api\client_api.py", line 322, in reload_client
url = binstar_client.utils.get_config()['url']
File "C:\Users\home\anaconda3\lib\site-packages\binstar_client\utils\config.py", line 249, in get_config
file_configs = load_file_configs(SEARCH_PATH)
File "C:\Users\home\anaconda3\lib\site-packages\binstar_client\utils\config.py", line 241, in load_file_configs
raw_data = collections.OrderedDict(kv for kv in itertools.chain.from_iterable(load_paths))
File "C:\Users\home\anaconda3\lib\site-packages\binstar_client\utils\config.py", line 241, in
raw_data = collections.OrderedDict(kv for kv in itertools.chain.from_iterable(load_paths))
File "C:\Users\home\anaconda3\lib\site-packages\binstar_client\utils\config.py", line 221, in _dir_yaml_loader
yield filepath, load_config(filepath)
File "C:\Users\home\anaconda3\lib\site-packages\binstar_client\utils\config.py", line 205, in load_config
data = yaml_load(fd)
File "C:\Users\home\anaconda3\lib\site-packages\binstar_client\utils\yaml.py", line 12, in yaml_load
return safe_load(stream)
File "C:\Users\home\anaconda3\lib\site-packages\yaml\__init__.py", line 162, in safe_load
return load(stream, SafeLoader)
File "C:\Users\home\anaconda3\lib\site-packages\yaml\__init__.py", line 112, in load
loader = Loader(stream)
File "C:\Users\home\anaconda3\lib\site-packages\yaml\loader.py", line 34, in __init__
Reader.__init__(self, stream)
File "C:\Users\home\anaconda3\lib\site-packages\yaml\reader.py", line 85, in __init__
self.determine_encoding()
File "C:\Users\home\anaconda3\lib\site-packages\yaml\reader.py", line 135, in determine_encoding
self.update(1)
File "C:\Users\home\anaconda3\lib\site-packages\yaml\reader.py", line 169, in update
self.check_printable(data)
File "C:\Users\home\anaconda3\lib\site-packages\yaml\reader.py", line 143, in check_printable
raise ReaderError(self.name, position, ord(character),
yaml.reader.ReaderError: unacceptable character #x0000: special characters are not allowed
in "C:\Users\home\.continuum\anaconda-client\config.yaml", position 0
According to github the problem lies with "config.yaml" file in C:\Users\axith.continuum\anaconda-client\config.yaml , rename it to config.old or delete it

function() takes 1 positional argument but 2 were given

I'm trying to clone this Django repo and run it on my local machine, but I've run into the classic function() takes 1 positional argument but 2 were given error.
After cloning the repo I created a virtual environment and installed all the dependencies,
But when I run
py manage.py migrate
I get the above-mentioned error.
What's confusing me is that the error is occurring in a python file automatically generated in the virtual environment and according to other questions on SO about this, the code seems correct.
Here's the trace
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\core\management\__init__.py", line 395, in execute
django.setup()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django_prometheus\apps.py", line 22, in ready
ExportMigrations()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django_prometheus\migrations.py", line 39, in ExportMigrations
executor = MigrationExecutor(connections[alias])
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
self.build_graph()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\loader.py", line 220, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations
if self.has_table():
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor
self.ensure_connection()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 202, in connect
self.init_connection_state()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\mysql\base.py", line 245, in init_connection_state
if self.features.is_sql_auto_is_null_enabled:
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\mysql\features.py", line 150, in is_sql_auto_is_null_enabled
return self.connection.mysql_server_data['sql_auto_is_null']
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\mysql\base.py", line 366, in mysql_server_data
with self.temporary_connection() as cursor:
File "C:\Python\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 603, in temporary_connection
with self.cursor() as cursor:
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 237, in _cursor
return self._prepare_cursor(self.create_cursor(name))
TypeError: create_cursor() takes 1 positional argument but 2 were given
Base.py in the virtual environment.
def _cursor(self, name=None):
self.ensure_connection()
with self.wrap_database_errors:
return self._prepare_cursor(self.create_cursor(name))
def create_cursor(self, name=None):
"""Create a cursor. Assume that a connection is established."""
raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a create_cursor() method')
I was hoping that someone could try cloning the repo and running it locally to see whether they could recreate the problem or maybe help me understand what's causing it.

Celery not revoked tasks

I have a task on Celery 4.1. I want to revoke this task like
task.revoke()
all is nang up on this time, then I raise KeyboardInterrupt and have the same Traceback:
File "/usr/local/lib/python3.6/queue.py", line 164, in get
self.not_empty.wait()
File "/usr/local/lib/python3.6/threading.py", line 295, in wait
waiter.acquire()
After that, I can revoke tasks.
full traceback with gevent.
I'm also try to change broker to RabbitMQ and has the same error
Traceback (most recent call last):
File "/usr/src/app/backend/tests.py", line 779, in test_reactivate_contract
contract.activate_contract(paid=True, reactivate=True)
File "/usr/src/app/backend/models/contract.py", line 83, in activate_contract
revoke_task(self.celery_task)
File "/usr/src/app/backend/celery/tasks.py", line 128, in revoke_task
app.control.revoke(task_id)
File "/usr/local/lib/python3.6/site-packages/celery/app/control.py", line 210, in revoke
}, **kwargs)
File "/usr/local/lib/python3.6/site-packages/celery/app/control.py", line 436, in broadcast
limit, callback, channel=channel,
File "/usr/local/lib/python3.6/site-packages/kombu/pidbox.py", line 315, in _broadcast
serializer=serializer)
File "/usr/local/lib/python3.6/site-packages/kombu/pidbox.py", line 285, in _publish
with self.producer_or_acquire(producer, chan) as producer:
File "/usr/local/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.6/site-packages/kombu/pidbox.py", line 247, in producer_or_acquire
with self.producer_pool.acquire() as producer:
File "/usr/local/lib/python3.6/site-packages/kombu/resource.py", line 83, in acquire
R = self.prepare(R)
File "/usr/local/lib/python3.6/site-packages/kombu/pools.py", line 62, in prepare
p = p()
File "/usr/local/lib/python3.6/site-packages/kombu/utils/functional.py", line 203, in __call__
return self.evaluate()
File "/usr/local/lib/python3.6/site-packages/kombu/utils/functional.py", line 206, in evaluate
return self._fun(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/site-packages/kombu/pools.py", line 42, in create_producer
conn = self._acquire_connection()
File "/usr/local/lib/python3.6/site-packages/kombu/pools.py", line 39, in _acquire_connection
return self.connections.acquire(block=True)
File "/usr/local/lib/python3.6/site-packages/kombu/resource.py", line 78, in acquire
R = self._resource.get(block=block, timeout=timeout)
File "/usr/local/lib/python3.6/queue.py", line 164, in get
self.not_empty.wait()
File "/usr/local/lib/python3.6/threading.py", line 295, in wait
waiter.acquire()
File "/usr/local/lib/python3.6/site-packages/gevent/thread.py", line 84, in acquire
return BoundedSemaphore.acquire(self, blocking, timeout)
File "src/gevent/_semaphore.py", line 198, in gevent._semaphore.Semaphore.acquire (src/gevent/gevent._semaphore.c:4541)
File "src/gevent/_semaphore.py", line 226, in gevent._semaphore.Semaphore.acquire (src/gevent/gevent._semaphore.c:4367)
File "src/gevent/_semaphore.py", line 166, in gevent._semaphore.Semaphore._do_wait (src/gevent/gevent._semaphore.c:3562)
File "/usr/local/lib/python3.6/site-packages/gevent/hub.py", line 630, in switch
return RawGreenlet.switch(self)
gevent.hub.LoopExit: ('This operation would block forever', <Hub at 0x7fd1b0269210 epoll default pending=0 ref=0 fileno=4 resolver=<gevent.resolver_thread.Resolver at 0x7fd1a7843c50 pool=<ThreadPool at 0x7fd1a78432b0 0/1/10>> threadpool=<ThreadPool at 0x7fd1a78432b0 0/1/10>>)
I'm using Python 3.6, Celery 4.1, Django 1.11, and Redis.

Why does pyramid give exception of zipimporter.get_filename()

I am writing a simple pyramid application, and I try to run it pserve development.ini.
I got this:
Traceback (most recent call last):
File "/apps/my/python/packages/.mytest/current/bin/pserve", line 5, in <module>
sys.exit(pyramid.scripts.pserve.main())
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/scripts/pserve.py", line 51, in main
return command.run()
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/scripts/pserve.py", line 316, in run
global_conf=vars)
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/scripts/pserve.py", line 340, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/util.py", line 58, in fix_call
reraise(*exc_info)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/compat.py", line 23, in reraise
exec('raise t, e, tb', dict(t=t, e=e, tb=tb))
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/util.py", line 55, in fix_call
val = callable(*args, **kw)
File "/users/is/pypi/egg_cache/at/mytest-1.9.0-py2.7.egg//mytest/__init__.py", line 108, in main
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/config/__init__.py", line 930, in scan
ignore=ignore)
File "/users/is/pypi/egg_cache/v/venusian-1.0a7-py2.7.egg/venusian/__init__.py", line 187, in scan
fn = loader.get_filename()
TypeError: zipimporter.get_filename() takes exactly 1 argument (0 given)
anyone could tell me how it comes?
Ok. I choose not to delete this question as I believe it might help other people who have the same problems.
Basically venusian does not support zipped egg. So when you produce your egg for pyramid, do not do it as zip egg.

Nose Test Error

I am using the command
nosetests -v --with-coverage --cover-package=task --cover-erase --cover-html-dir=cover --cover-html --with-xunit task
to run the test cases
but in the end after running all the testcases I get the nosetests.xml blank and the following error.
Traceback (most recent call last):
File "/home/nishant-un/env/bin/nosetests", line 9, in <module>
load_entry_point('nose==1.0.0', 'console_scripts', 'nosetests')()
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/core.py", line 118, in __init__
**extra_args)
File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
self.runTests()
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/core.py", line 197, in runTests
result = self.testRunner.run(self.test)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/core.py", line 61, in run
test(result)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/case.py", line 45, in __call__
return self.run(*arg, **kwarg)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/case.py", line 138, in run
result.addError(self, err)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/proxy.py", line 118, in addError
formatted = plugins.formatError(self.test, err)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 94, in __call__
return self.call(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 136, in chain
result = meth(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/plugins/logcapture.py", line 223, in formatError
test.capturedLogging = records = self.formatLogRecords()
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/plugins/logcapture.py", line 231, in formatLogRecords
return [safe_str(format(r)) for r in self.handler.buffer]
File "/usr/lib/python2.7/logging/__init__.py", line 723, in format
return fmt.format(record)
File "/usr/lib/python2.7/logging/__init__.py", line 464, in format
record.message = record.getMessage()
File "/usr/lib/python2.7/logging/__init__.py", line 328, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
I have tried almost everything that i found in google. Even deleted .coverage file and all .pyc but it still shows the same error.Any Idea..?
This TypeError is because of mixing different formats.
Your error is inside formatLogRecords()
Instead of:
msg = msg % self.args
You should use format():
myMsg = "{} {} {} {} {}".format(param1, param2, param3, param4)
And even much better approach will be:
args = ['1', '2', '3', '4']
myMsg = (' '.join('{}'.format(k) for k in args))
Result:
>>> 1 2 3 4
That way your args can be with a flexible.
One thing to try is to run nose with no log capturing --nologcapture. Most likely you have a rogue logging somewhere at the import level, and it chokes nose before tests can run.
You can usually expose those bugs easily if you just run python task.py on your test files - the error will get thrown immediately.
If this still does not solve your problem, try running nose within python using nose.run() within your test __main__ function, and fire it off with python -m pdb task.py it will let you debug such errors, even if --pdb option in nose does not work.

Categories