Feb-17-2020, 08:52 PM
Hi guys,
I'm hoping this is something simple I'm missing... but for some reason I'm unable to import a list from another module, the contents always show as nothing.
module 1: checks a database and populates a job number into a list
I forgot to mention that yes both modules/functions are called but I'm doing it via multiprocessing... which i suspect has to do with the issue in why I can't pass the object between the processes.
I'm hoping this is something simple I'm missing... but for some reason I'm unable to import a list from another module, the contents always show as nothing.
module 1: checks a database and populates a job number into a list
#!C:\Program Files\Python37\python.exe from logger import Logger from configparser import ConfigParser from connectDb import connectDb, disconnectDb import time config = ConfigParser() config.read('config.ini') q = [] jobsInQueue=0 lastSent='' pullId=config.get('QUERY', 'pullId') module='[Job Queue]' def jobQueue(): global lastSent, jobsInQueue, q cnxn=connectDb() cursor=cnxn.cursor() cursor.execute(pullId) r=cursor.fetchone() lastSent=r print(module + ' module started.') while True: cursor.execute(pullId) r=cursor.fetchone() s=r if r!=lastSent: strips(s) lastSent=s jobsInQueue+=1 q.append(s) print('New outbound sms detected, placed in queue...') print(str(jobsInQueue) + ' total jobs in queue.') Logger.sendLog('Job ' + str(s) + ' detected and placed in queue', 0) time.sleep(1) else: time.sleep(1) passModule 2, just would like to import the list (and count of items in the list) so I can use it as a queue... however, the list and other object always show as empty and 0
from jobQueue import q, jobsInQueue import time def send(): while True: print(jobsInQueue) print(q) time.sleep(4)
I forgot to mention that yes both modules/functions are called but I'm doing it via multiprocessing... which i suspect has to do with the issue in why I can't pass the object between the processes.