Error while executing basic code in Locust - locust

from locust import Locust, TaskSet
def login(l):
print("I am logged In")
def logout(m):
print("I am logged Out")
class UserBehaviour(TaskSet):
task=[login,logout]
class User(Locust):
task_set = UserBehaviour
Error Message---
(venv) C:\pythnprojects\LearnLocustProject\venv\locust_test>locust -f firstlocust.py
[2020-03-11 00:38:57,259] DELLXPS/INFO/locust.main: Starting web monitor at *:8089
[2020-03-11 00:38:57,259] DELLXPS/INFO/locust.main: Starting Locust 0.11.0
[2020-03-11 00:39:05,581] DELLXPS/INFO/locust.runners: Hatching and swarming 1 clients at the rate 1 clients/s...
[2020-03-11 00:39:05,585] DELLXPS/ERROR/stderr: Traceback (most recent call last):
File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 358, in run
self.schedule_task(self.get_next_task())
File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 419, in get_next_task
return random.choice(self.tasks)
File "C:\DOWNLOADS\lib\random.py", line 290, in choice
raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence
[2020-03-11 00:39:06,582] DELLXPS/INFO/locust.runners: All locusts hatched: User: 1
[2020-03-11 00:39:06,591] DELLXPS/ERROR/stderr: Traceback (most recent call last):
File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 358, in run
self.schedule_task(self.get_next_task())
File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 419, in get_next_task
return random.choice(self.tasks)
File "C:\DOWNLOADS\lib\random.py", line 290, in choice
raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence
[2020-03-11 00:39:07,597] DELLXPS/ERROR/stderr: Traceback (most recent call last):
File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 358, in run
self.schedule_task(self.get_next_task())
File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 419, in get_next_task
return random.choice(self.tasks)
File "C:\DOWNLOADS\lib\random.py", line 290, in choice
raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence

It looks like you've misspelled tasks (it currently seems to say task).

Related

python anaconda3 jupyter error:Traceback (most recent call last)

I usually anaconda.navigator with 'jupyter notebook' to launch the jupyter notebook .
but this message is showed up
Last login: Mon Oct 10 10:16:34 on ttys000
/opt/anaconda3/bin/jupyter_mac.command ; exit;
[comma7456#~]$/opt/anaconda3/bin/jupyter_mac.command ; exit;
Traceback (most recent call last):
File "/opt/anaconda3/bin/jupyter-notebook", line 11, in <module>
sys.exit(main())
File "/opt/anaconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 264, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/opt/anaconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 845, in launch_instance
app.initialize(argv)
File "/opt/anaconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 88, in inner
return method(app, *args, **kwargs)
File "/opt/anaconda3/lib/python3.9/site-packages/notebook/notebookapp.py", line 2147, in initialize
self.init_resources()
File "/opt/anaconda3/lib/python3.9/site-packages/notebook/notebookapp.py", line 1706, in init_resources
resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard))
ValueError: current limit exceeds maximum limit
logout
Saving session...

How make a correct query from pymongo

I am using pymongo to subset a collection in mongodb, I am having problems with the syntax of the query, this is my query:
import pymongo
client=pymongo.MongoClient("localhost",27017)
db=client("publications")
collec=db("zikaVirus2")
pipeline=db.collec.aggregate([
{"$match":{"fullText":{"$exists": "true"}}},
{"$out": "pub_fulltext"}
])
db.pub_fulltext.aggregate(pipeline)
I am getting this error:
Traceback (most recent call last):
File "genColFulltext.py", line 3, in <module>
db=client("publications")
TypeError: 'MongoClient' object is not callable
UPDATE 1
If I do
import pymongo
client=pymongo.MongoClient("localhost",27017)
db=client.publications
collec=db.zikaVirus2
pipeline=db.collec.aggregate([
{"$match":{"fullText":{"$exists": "true"}}},
{"$out": "pub_fulltext"}
])
db.pub_fulltext.aggregate(pipeline)
I get
Traceback (most recent call last):
File "genColFulltext.py", line 11, in <module>
db.pub_fulltext.aggregate(pipeline)
File "/home/danielo/.local/lib/python3.5/site-packages/pymongo /collection.py", line 2397, in aggregate
**kwargs)
File "/home/danielo/.local/lib/python3.5/site-packages/pymongo/collection.py", line 2242, in _aggregate
common.validate_list('pipeline', pipeline)
File "/home/danielo/.local/lib/python3.5/site-packages/pymongo/common.py", line 428, in validate_list
raise TypeError("%s must be a list" % (option,))
TypeError: pipeline must be a list
UPDATE 2
This code runs without problems, but it make nothing of his purpose, the collection pub_fulltext have anything, when it should have data.
import pymongo
client=pymongo.MongoClient("localhost",27017)
db=client.publications
collec=db.zikaVirus2
pipeline=db.collec.aggregate([
{"$match":{"fullText":{"$exists": "true"}}},
{"$out": "pub_fulltext"}
])
for item in pipeline:
db.pub_fulltext.aggregate(item)
Then I try this:
import pymongo
client=pymongo.MongoClient("localhost",27017)
db=client.publications
collec=db.zikaVirus2
pipeline=[db.collec.aggregate([
{"$match":{"fullText":{"$exists": "true"}}},
{"$out": "pub_fulltext"}
])]
for item in db.collection.aggregate(pipeline):
db.collection.aggregate(item)
Getting this error:
Traceback (most recent call last):
File "genColFulltext.py", line 10, in <module>
for item in collection.aggregate(pipeline):
Traceback (most recent call last): File "genColFulltext.py", line 10, in <module>
for item in db.collection.aggregate(pipeline): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/collection.py", line 2397, in aggregate
**kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/collection.py", line 2304, in _aggregate
client=self.__database.client) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/pool.py", line 584, in command
self._raise_connection_failure(error) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/pool.py", line 745, in _raise_connection_failure
raise error File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/pool.py", line 579, in command
unacknowledged=unacknowledged) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/network.py", line 114, in command
codec_options, ctx=compression_ctx) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/message.py", line 679, in _op_msg
flags, command, identifier, docs, check_keys, opts) bson.errors.InvalidDocument: Cannot encode object: <pymongo.command_cursor.CommandCursor object at 0x1008e4198>

KeyError: 'found' on Elastic2DocManager when syncing data from MongoDB

From MongoDB to Elastic Search(5.6.5), I sync the database with Mongo-Connector using Elastic2DocManager:
mongo-connector -m localhost:27017 -t localhost:9200 -d elastic2_doc_manager
After seeing some update on docs.deleted of mongodb_meta on Elastic Search:
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open mongodb_meta 3wd6OjTT6tD3f6ZGezZw 5 1 1337173 8372 192.9mb 192.9mb
mongo-connector stops working with below error:
2018-07-11 07:16:41,977 [WARNING] elasticsearch:97 - POST http://localhost:9200/_bulk [status:N/A request:10.003s]
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "c:\programdata\anaconda3\lib\http\client.py", line 1331, in getresponse
response.begin()
File "c:\programdata\anaconda3\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "c:\programdata\anaconda3\lib\http\client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "c:\programdata\anaconda3\lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
...
Exception in thread Thread-1:
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "c:\programdata\anaconda3\lib\site-packages\mongo_connector\doc_managers\elastic2_doc_manager.py", line 150, in run
self._docman.send_buffered_operations()
File "c:\programdata\anaconda3\lib\site-packages\mongo_connector\doc_managers\elastic2_doc_manager.py", line 482, in send_buffered_operations
action_buffer = self.BulkBuffer.get_buffer()
File "c:\programdata\anaconda3\lib\site-packages\mongo_connector\doc_managers\elastic2_doc_manager.py", line 696, in get_buffer
self.update_sources()
File "c:\programdata\anaconda3\lib\site-packages\mongo_connector\util.py", line 35, in wrapped
return f(*args, **kwargs)
File "c:\programdata\anaconda3\lib\site-packages\mongo_connector\doc_managers\elastic2_doc_manager.py", line 628, in update_sources
if ES_doc['found']:
KeyError: 'found'
What is the reason for this error?
Make sure the versions are compatible.
The required python packages are installed, this is my requirements.txt look like.
astroid==1.6.5
autopep8==1.3.5
certifi==2018.8.24
elasticsearch==6.3.1
elasticsearch-dsl==6.2.1
isort==4.3.4
lazy-object-proxy==1.3.1
mccabe==0.6.1
pycodestyle==2.4.0
pylint==1.9.2
pymongo==3.7.1
rope==0.11.0
six==1.11.0
urllib3==1.23
wrapt==1.10.11

Error while start openerp

i have installed openerp. i have created postgres database. While i open ¨localhost:8060¨ in browser, display the followin error:
Client Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/http.py", line 204, in dispatch
response["result"] = method(self, **self.params)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/controllers/main.py", line 761, in get_list
monodb = db_monodb(req)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/controllers/main.py", line 129, in db_monodb
return db_redirect(req, True)[0]
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/controllers/main.py", line 109, in db_redirect
dbs = db_list(req, True)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/controllers/main.py", line 90, in db_list
dbs = proxy.list(force)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/session.py", line 30, in proxy_method
result = self.session.send(self.service_name, method, *args)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/session.py", line 103, in send
raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)
Server Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/session.py", line 89, in send
return openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/netsvc.py", line 292, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/service/web_services.py", line 122, in dispatch
return fn(*params)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/service/web_services.py", line 359, in exp_list
cr = db.cursor()
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/sql_db.py", line 484, in cursor
return Cursor(self._pool, self.dbname, serialized=serialized)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/sql_db.py", line 182, in __init__
self._cnx = pool.borrow(dsn(dbname))
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/sql_db.py", line 377, in _locked
return fun(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/sql_db.py", line 440, in borrow
result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
OperationalError: FATAL: role "bala" does not exist
otherwise i started like following ¨openerp-server start¨, error following like
Traceback (most recent call last):
File "/usr/local/bin/openerp-server", line 5, in <module>
pkg_resources.run_script('openerp==7.0-20140110-002122', 'openerp-server')
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1235, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/EGG-INFO/scripts/openerp-server", line 5, in <module>
openerp.cli.main()
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/cli/__init__.py", line 51, in main
__import__(m)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/modules/module.py", line 133, in load_module
mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/l10n_si/__init__.py", line 22, in <module>
import account_wizard
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/l10n_si/account_wizard.py", line 22, in <module>
import tools
ImportError: No module named tools
Anyone help for error correction. i cannot clear this error even two days i spend for this.
OperationalError: FATAL: role "bala" does not exist
A user that you have told OpenERP to use does not exist in the database. You probably need to create it. I expect you missed one or more installation steps.
Look for a CREATE USER, CREATE ROLE, or createuser command in the instructions.
GRANT commands or a database ownership assignment may also be nececssary depending on what the user is supposed to be able to do.
(It might also be assumed that you'll know to create the user to connect to the DB as).

Celery log shows cleanup failed

I am using celery with django. I see an error when I lookup the celery log for the automatically scheduled cleanup. I am not sure what this means, and the implications of not doing the cleanup. Any help is appreciated.
[2013-09-28 23:00:00,204: ERROR/MainProcess] Task celery.backend_cleanup[65af1634-374a-4068-b1a5-749b70f7c78d] raised exception: NotImplementedError('No updates',)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/celery-3.0.15-py2.7.egg/celery/task/trace.py", line 228, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/celery-3.0.15-py2.7.egg/celery/task/trace.py", line 415, in __protected_call__
return self.run(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/celery-3.0.15-py2.7.egg/celery/app/builtins.py", line 58, in backend_cleanup
app.backend.cleanup()
File "/usr/local/lib/python2.7/dist-packages/djcelery/backends/database.py", line 58, in cleanup
model._default_manager.delete_expired(expires)
File "/usr/local/lib/python2.7/dist-packages/djcelery/managers.py", line 110, in delete_expired
self.get_all_expired(expires).update(hidden=True)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 469, in update
rows = query.get_compiler(self.db).execute_sql(None)
File "/usr/local/lib/python2.7/dist-packages/djangotoolbox/db/basecompiler.py", line 376, in execute_sql
raise NotImplementedError('No updates')