Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global variable issue #61

Closed
MyraBaba opened this issue Jul 9, 2019 · 9 comments
Closed

Global variable issue #61

MyraBaba opened this issue Jul 9, 2019 · 9 comments

Comments

@MyraBaba
Copy link

MyraBaba commented Jul 9, 2019

I have definition in the beginning of my python code :


RESET = "\033[0;0m"
RED   = "\033[1;31m"
BLUE  = "\033[1;34m"
CYAN  = "\033[1;36m"
GREEN = "\033[0;32m"
BOLD    = "\033[;1m"
REVERSE = "\033[;7m"

and in my of my function :


def on_connect(client, userdata, flags, rc):
    print(RED ,"** Kozmos bizimle ** Connected flags" + str(flags) + "result code " \
                 + str(rc) + "client1_id " , RESET)

I compiled with

pyconcrete-admin.py compile --source=_mqt_p.py --pye

and when I run ti gives :

log: Caught exception in on_connect: name 'RED' is not defined

any idea ?

@Falldog
Copy link
Owner

Falldog commented Jul 10, 2019

Please post more information, how do you compile / execute the scripts, and the entry point file is .py or .pye?

@MyraBaba
Copy link
Author

I compiled :

pyconcrete-admin.py compile --source=_mqt_p.py --pye

and run :

pyconcrete mqt_.pye

@MyraBaba
Copy link
Author

MyraBaba commented Jul 11, 2019

@Falldog any idea *

@Falldog
Copy link
Owner

Falldog commented Jul 12, 2019

Not really, can you provide the whole file to me for testing?

@MyraBaba
Copy link
Author

Hi,
I am creating worker as below :

`num_fetch_threads = 1
model_worker_number = 1
update_db_worker_number = 1
enroll_worker_number = 1
online_enrollment_worker_number = 1

###QUEUEU s
###QUEUEU s

result_queue            = queue.Queue()      ##PUBLISHER WORKER
model_worker_queue      = queue.Queue()      ##Model worker thread
enrolment_queue         = queue.Queue()      ##ENROLMENT queue
online_enrollment_queue = queue.Queue()      ## ONLINE ENROLMENT
result_enrollment_queue = queue.Queue()
indexed_insert_db_queue = queue.Queue()      ## Sisteme eklenen personel'i indexed olarak güncelle

for i in range(update_db_worker_number):
    update_db_worker = Thread(target=update_data_sql_deamon , args=( indexed_insert_db_queue,))
    update_db_worker.setDaemon(True)
    update_db_worker.start()

for i in range(model_worker_number):
    model_worker = Thread(target=model_worker_deamon , args=(i , model_worker_queue,))
    model_worker.setDaemon(True)
    model_worker.start()

for i in range(enroll_worker_number):
    enrolment_worker = Thread(target=enrolment_deamon , args=(enrolment_queue,))
    enrolment_worker.setDaemon(True)
    enrolment_worker.start()

for i in range(online_enrollment_worker_number):
    online_enroll_worker = Thread(target=online_enrollment_deamon , args=(online_enrollment_queue,))
    online_enroll_worker.setDaemon(True)
    online_enroll_worker.start()

###SEND ENROLLMENT RESULT
for i in range(enroll_worker_number):
    send_enrollment_worker = Thread(target=send_enrollment_result_deamon , args=(result_enrollment_queue,))
    send_enrollment_worker.setDaemon(True)
    send_enrollment_worker.start()
`

In this threads when i used pyconcrete def funtions not aware of the global imports and the variables.

I already imported sqlite cv2 and numpy at the top but in threads def it says cant found.

@Falldog
Copy link
Owner

Falldog commented Jul 12, 2019

It's threading issue, duplicate issue with #60

@Falldog
Copy link
Owner

Falldog commented Jul 13, 2019

Please try the latest code, it should be fixed

@MyraBaba
Copy link
Author

compiling from the lates code from here right?

I will and let you know
thx

@MyraBaba
Copy link
Author

The latest code is working without any problem.

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants