Skip to content

possible bug in awsiotsdk python ?

0

I have a function:

def get_thing_shadow_request(thingName, shadowName):
try:

    ipc_client_shadow       = awsiot.greengrasscoreipc.connect()  
    get_thing_shadow_request = GetThingShadowRequest()  
    get_thing_shadow_request.thing_name = thingName  
    get_thing_shadow_request.shadow_name = shadowName  
    op = ipc_client_shadow.new_get_thing_shadow()  
    op.activate(get_thing_shadow_request)  
    fut = op.get_response()  
    result = fut.result(10)  
    return result.payload  

except BaseException as err:  
    g_logger.error("EXCEPTION get_thing_shadow_request  thingname {}, shadowname {} error {} ".format(thingName, shadowName, err))  
    return ""  

that i call multiple times and it works fine. however on the 1023rd call ( this seems awfully close to a 1024 magic number btw) of this function it stops working with the following error:

EXCEPTION get_thing_shadow_request count:1025, thingname smartdvr-1423019132001, shadowname streamcontrol error 46 (AWS_ERROR_SYS_CALL_FAILURE): System call failure

one other note is that 1 out of 3 of my calls is asking for a shadow that doesn't exist (i'm checking to see if it exists and if it fails i know it doesn't)

i can't see anything unusual in greengrass.log

Edited by: clogwog on Dec 2, 2021 12:14 PM

asked 5 years ago603 views

3 Answers
0
Accepted Answer

Hello,
Looks like you're calling connect inside the method, so that means that you're calling connect 1023 times and thus creating 1023 threads and socket connections.

You should only ever connect one time and then reuse the client for all future calls. This should resolve your issue as well as be more efficient and fast.
Cheers,
Michael

AWS
EXPERT

answered 5 years ago

0

Well...if you put it like that.... yes.. this is less than optimal :)

thank you Michael! It all works well now.
Tom

answered 5 years ago

0

Tom,
I'm very glad to hear that solution worked for you.

Have a great day.
Cheers,
Michael

AWS
EXPERT

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.