1

Hi all I need help with my Python 3 program

I have a project with a card reader which is attached to a Raspberry pi 3 that has single core CPU (Number of core matters when it comes to threding If I am not mistaken) What I have done so far is running an infinite loop and inside that loop waiting for new cards and when new cards appear, write their number to a text file in JSON format. So far it works well. Right here I need a parallel job inside my program that look for updates in that file and uploaded them to the server without blocking main card reader loop. What I mean looks something like this:

def sync_to_the_cloud():
    read_file()
    sync()

def main():
    while True:
        newCard = wait_for_card():
            if newCard is not None:
                write_to_file():

Which python library should I use for this? I read a lot and I am confused now. threading, multiprocessing or asyncio? I also confused with the terms. What I want is called concurrent program or asynchronous program?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.