I have this code that works fine for the first run on a locust.io deployed server, but when i start/stop to make a new run i get multiple errors, in regard with the list. Could you guyz help me to be able to cycle it?
from locust import HttpUser, task, between, SequentialTaskSet, events
import uuid
import json
import csv
import logging, sys, random, os
with open('somecsv.csv', 'r') as f:
reader = csv.reader(f)
user= list(reader)
#print(user)
class somethingclass(SequentialTaskSet):
def on_start(self):
if len(user) > 0:
self.id= str(user.pop()).strip("][''")
@task
def someting(self):
do something with self.id request
@task
def someting2(self):
do something with self.id request
class Main(HttpUser):
wait_time = between(5, 10)
tasks = [somethingclass]
def _init_(self, *args, **kwargs):
super(Main, self)._init_(*args, **kwargs)
errors are:
[2020-08-18 23:06:50,899] PC/ERROR/locust.user.task: 'somethingclass' object has no attribute 'id' Traceback (most recent call last): File "c:\windows\system32\src\locust\locust\user\task.py", line 284, in run self.execute_next_task() File "c:\windows\system32\src\locust\locust\user\task.py", line 309, in execute_next_task self.execute_task(self._task_queue.pop(0)) File "c:\windows\system32\src\locust\locust\user\task.py", line 321, in execute_task task(self) File "C:\Users\user\Desktop\Work\Chipico Chip Transfer\chiptransfer_load.py", line 44, in someting "uuid": '%s' % self.id, AttributeError: 'somethingclass' object has no attribute 'id'