TypeError: dict object is not callable (inside Thread function)

128 views
Skip to first unread message

Hima Bindu chowdary

unread,
Oct 17, 2021, 8:56:04 AM10/17/21
to Django users
Hi guys, 


I am getting an error in a program which is using threading to perform functions simultaneously, this process is a  job which is run once per hour, The data that comes in is from a view in sql.

The function that we call in target arg returns a dictionary and says 
"dict object is not callable".
Inside the function , we return a dictionary in the end.
My doubt is what should we return in this function ..if I dont return anything will it affect any other thread??

what my code looks like :
inside the jobs in django I call this function


def ticket_booking():  
  
    query = " SELECT * FROM vw_ticket_list;"  

    ttd = []
    try:
        result = query_to_dicts(query)
        tickets = json.loads(to_json(result))
        if tickets:
            # Calling the vaccination push message (php).
            for ticket in tickets:
            
                # Getting Generic details used by all categories
                full_name = tickets['full_name'] 
                gender = tickets['gender']  
                email =tickets[email]

                if tickets['language_id'] == 1:  #book english movie tickets 
                   
                    # Calling the function inside the Thread for a Syncronuz Call (Wait and Watch)
                    myThread = threading.Thread(target=book_english(email, full_name))
                    myThread.start()  
                    myThread.join()  

                if tickets['language_id']  == 2:  # book italian movie tickets 
                    myThread = threading.Thread(target=book_italian( email, full_name, gender))
                    myThread.start()  # Starting the Thread
                    myThread.join() #Will return here if sth is returned

as you can see in code comments ..if book italian function returns sth , only then it can return here and I have 5 threads in total to excute simultaneously...book italian function is like :

def book_italian(email,fullname,gender):
try
    ###posts data to another server #
    b=requests.post(some postdata)

     a =log.objects.create(log data from b in crct format)
     return a--->{"Message":"Log created successfully"}

a is type class dict and I tried to change it to many types still gives me same error
any suggestions or alternatives,workarounds are welcome, this job is not running when run in crontab.

Thanks in advance.




Reply all
Reply to author
Forward
0 new messages