def worker(s, pool, q, str1, VMs, vml, adbport, count, adbl, results, fcnt):
    #global assignments
    global beanstalk

    name = multiprocessing.current_process().name

    formatter = logging.Formatter(fmt=LOGFORMAT,datefmt=LOGDATEFORMAT)
    handler = logging.FileHandler("worker.log")
    handler.setFormatter(formatter)

    wlogger = logger.getChild("worker" + name)
    wlogger.setLevel(logging.DEBUG)
    wlogger.addHandler(handler)

    with s:
        pool.makeActive(name)
	while True:
		#funky kill pill
		content = q.get()
		q.put(content)
        	if content == "die":
			wlogger.info( name + ":" + " is committing suicide")
			pool.makeInactive(name)
			sys.exit(0)
		else:
			#logger.info( 'Now running: %s %s %s (%s)' % (str(pool), str1, content,adbport))
			wlogger.info( name + ":" + " is working...")

			#check for a job in the beanstalk Q
			#if not beanstalk:
			#	error_log('Re-establishing connection to beanstalkd')
			#	beanstalk = beanstalkc.Connection(host=BSHOST, port=BSPORT)
			#	beanstalk.watch(BSMSBOXQ)
			#	beanstalk.use(BSMSBOXQ)
			#	beanstalk.ignore('default')
			rebeanstalk()

			#all this checking is just "best effort" another thread may still reserve first
			if beanstalk.tubes() not in BSMSBOXQ:
					wlogger.info( name + ":" + "there are no samples in the beanstalk")
			else:
				arejobs = beanstalk.peek_ready()
				if arejobs is None:
					wlogger.info( name + ":" + "there are no samples ready in the beanstalk")
					time.sleep(VM_POLL_REST)
				else:

					#we want to reserve, not peak_ready because if we can't process, we want to release with a delay later
					beansalkjob = None
					try:
						beanstalkjob = beanstalk.reserve()
					except:
						wlogger.info( name + ": " + "beanstalk reserve error, probably out of jobs")

					#if there was a job and we got it then queue up analysis
					job = None
					if beanstalkjob:
						try:
							job = eval(beanstalkjob.body)
						except:
							error_log('ERROR: could not eval job - invalid job')
							beanstalkjob.delete()
							wlogger.info( name + ":" + "BAD JOB, deleting")
							#return False
							continue
						if job:
							#is there a VM compatible with this sample that is ready to be used?
							m = findCompatibleVM(job,VMs,vml)
							if m is not None:
								#wlogger.info( name + ":" + "using VM " + str(m))
								wlogger.info( name + ":" + "using VM " + str(m) + " for " + job['basename'] + "(" + job['target'] + ")")
								#process sample

								#TODO this delete should really only happen if runInVM succeeds
								beanstalkjob.delete()
								if runInVM(m,job,VMs,adbport,vml,adbl,results, fcnt):
									#runInVM might take a while
									rebeanstalk()
									#delete from BSqueue if successfull
									#beanstalkjob.delete()
									count.value += 1
							
								#should never hit this due to live/die toggle		
								if flagTerminate:
									wlogger.info( name + ":" + "terminating?!")
									sys.exit(0)
								else:
									continue

								#put back into VMready Q
							else:
								#no VM found, put it back in the queue (nobody will process for 60 seconds
								beanstalkjob.release(delay=BSDELAY)
								wlogger.info( name + ":" + "requeuing job requiring a target version " + job['target'])
			#time.sleep(VM_POLL_REST)
dataset/ETHPy150Open tvidas/a5/scripts/bin/control.py/worker/swapped operands of `not in`