Skip to content

Suggested modification of sample code: "listen in a thread" #72

@ywshzh

Description

@ywshzh

from threading import Thread t = Thread(target=client.listen) t.start()
I used the code in the example to implement the function of sending SMS in django, but when listen() throws an exception, the thread terminates and the enquire_link packet loss, it will causes the server unbind.
My uwsgi server threads are set to 4, and 4 threads constantly rebind the server, it will resulting whith similar errors like: smpplib. exceptions. UnknownCommand Error: Unknown SMPP command code "0x428"

So,would the following modifications be better?
`
def listen():
while True:
try:
ecarxsmpp.client.listen()
except Exception:
print traceback.format_exc()

t = Thread(target=listen)
t.start()
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions