AWS | Syntax error in module': invalid syntax












-3















I have created python script which is uploaded as a zip file in AWS Lambda function with stompy libraries bundled in them.



Logs for python 2.7:-



Response:
null

Request ID:
"c334839f-ee46-11e8-8970-612f1dc92e41"

Function Logs:
START RequestId: c334839f-ee46-11e8-8970-612f1dc92e41 Version: $LATEST
CONNECTION Started
CONNECTION established
CONNECTION Subscribed
[WARNING] 2018-11-22T11:07:12.798Z c334839f-ee46-11e8-8970-612f1dc92e41 Unknown response frame type: '' (frame length was 3)
END RequestId: c334839f-ee46-11e8-8970-612f1dc92e41
REPORT RequestId: c334839f-ee46-11e8-8970-612f1dc92e41 Duration: 10027.75 ms Billed Duration: 10100 ms Memory Size: 128 MB Max Memory Used: 30 MB


My Code:-



import time
import boto3
import stomp

kinesis_client = boto3.client('kinesis')


class Listener(stomp.ConnectionListener):
msg_list =
def on_error(self, headers, message):
print('received an error "%s"' % message)

def on_message(self, headers, message):
print('received a message "%s"' % message)
kinesis_client.put_record(
StreamName='Purchasing',
Data=u'{}rn'.format(message).encode('utf-8'),
PartitionKey='0'
)


def lambda_handler(event, context):
conn = stomp.Connection(host_and_ports=[('b-4714-4441-8166-47aae158281a-1.mq.eu-central-1.amazonaws.com', 8162)])
lst = Listener()
conn.set_listener('Listener', Listener())
conn.start()
conn.connect(login='test_mq', passcode='test_mq')
conn.subscribe(destination='/queue/Purchasing', id='b-4714-4441-8166-47aae158281a', ack='auto')
message = lst.msg_list
print('Waiting for messages "%s"' % message)
time.sleep(10)
conn.disconnect()
return ''


I am not sure why my message is not showing up in my output,instead it always shows up "Response: null".










share|improve this question

























  • Please post your code as text, not a screenshot. We might need to copy and paste your code to our own text editors to reproduce your problem, and we can't do that from a graphic.

    – cdarke
    Nov 20 '18 at 14:46











  • @cdarke I have attached the code

    – user10664125
    Nov 20 '18 at 14:49
















-3















I have created python script which is uploaded as a zip file in AWS Lambda function with stompy libraries bundled in them.



Logs for python 2.7:-



Response:
null

Request ID:
"c334839f-ee46-11e8-8970-612f1dc92e41"

Function Logs:
START RequestId: c334839f-ee46-11e8-8970-612f1dc92e41 Version: $LATEST
CONNECTION Started
CONNECTION established
CONNECTION Subscribed
[WARNING] 2018-11-22T11:07:12.798Z c334839f-ee46-11e8-8970-612f1dc92e41 Unknown response frame type: '' (frame length was 3)
END RequestId: c334839f-ee46-11e8-8970-612f1dc92e41
REPORT RequestId: c334839f-ee46-11e8-8970-612f1dc92e41 Duration: 10027.75 ms Billed Duration: 10100 ms Memory Size: 128 MB Max Memory Used: 30 MB


My Code:-



import time
import boto3
import stomp

kinesis_client = boto3.client('kinesis')


class Listener(stomp.ConnectionListener):
msg_list =
def on_error(self, headers, message):
print('received an error "%s"' % message)

def on_message(self, headers, message):
print('received a message "%s"' % message)
kinesis_client.put_record(
StreamName='Purchasing',
Data=u'{}rn'.format(message).encode('utf-8'),
PartitionKey='0'
)


def lambda_handler(event, context):
conn = stomp.Connection(host_and_ports=[('b-4714-4441-8166-47aae158281a-1.mq.eu-central-1.amazonaws.com', 8162)])
lst = Listener()
conn.set_listener('Listener', Listener())
conn.start()
conn.connect(login='test_mq', passcode='test_mq')
conn.subscribe(destination='/queue/Purchasing', id='b-4714-4441-8166-47aae158281a', ack='auto')
message = lst.msg_list
print('Waiting for messages "%s"' % message)
time.sleep(10)
conn.disconnect()
return ''


I am not sure why my message is not showing up in my output,instead it always shows up "Response: null".










share|improve this question

























  • Please post your code as text, not a screenshot. We might need to copy and paste your code to our own text editors to reproduce your problem, and we can't do that from a graphic.

    – cdarke
    Nov 20 '18 at 14:46











  • @cdarke I have attached the code

    – user10664125
    Nov 20 '18 at 14:49














-3












-3








-3








I have created python script which is uploaded as a zip file in AWS Lambda function with stompy libraries bundled in them.



Logs for python 2.7:-



Response:
null

Request ID:
"c334839f-ee46-11e8-8970-612f1dc92e41"

Function Logs:
START RequestId: c334839f-ee46-11e8-8970-612f1dc92e41 Version: $LATEST
CONNECTION Started
CONNECTION established
CONNECTION Subscribed
[WARNING] 2018-11-22T11:07:12.798Z c334839f-ee46-11e8-8970-612f1dc92e41 Unknown response frame type: '' (frame length was 3)
END RequestId: c334839f-ee46-11e8-8970-612f1dc92e41
REPORT RequestId: c334839f-ee46-11e8-8970-612f1dc92e41 Duration: 10027.75 ms Billed Duration: 10100 ms Memory Size: 128 MB Max Memory Used: 30 MB


My Code:-



import time
import boto3
import stomp

kinesis_client = boto3.client('kinesis')


class Listener(stomp.ConnectionListener):
msg_list =
def on_error(self, headers, message):
print('received an error "%s"' % message)

def on_message(self, headers, message):
print('received a message "%s"' % message)
kinesis_client.put_record(
StreamName='Purchasing',
Data=u'{}rn'.format(message).encode('utf-8'),
PartitionKey='0'
)


def lambda_handler(event, context):
conn = stomp.Connection(host_and_ports=[('b-4714-4441-8166-47aae158281a-1.mq.eu-central-1.amazonaws.com', 8162)])
lst = Listener()
conn.set_listener('Listener', Listener())
conn.start()
conn.connect(login='test_mq', passcode='test_mq')
conn.subscribe(destination='/queue/Purchasing', id='b-4714-4441-8166-47aae158281a', ack='auto')
message = lst.msg_list
print('Waiting for messages "%s"' % message)
time.sleep(10)
conn.disconnect()
return ''


I am not sure why my message is not showing up in my output,instead it always shows up "Response: null".










share|improve this question
















I have created python script which is uploaded as a zip file in AWS Lambda function with stompy libraries bundled in them.



Logs for python 2.7:-



Response:
null

Request ID:
"c334839f-ee46-11e8-8970-612f1dc92e41"

Function Logs:
START RequestId: c334839f-ee46-11e8-8970-612f1dc92e41 Version: $LATEST
CONNECTION Started
CONNECTION established
CONNECTION Subscribed
[WARNING] 2018-11-22T11:07:12.798Z c334839f-ee46-11e8-8970-612f1dc92e41 Unknown response frame type: '' (frame length was 3)
END RequestId: c334839f-ee46-11e8-8970-612f1dc92e41
REPORT RequestId: c334839f-ee46-11e8-8970-612f1dc92e41 Duration: 10027.75 ms Billed Duration: 10100 ms Memory Size: 128 MB Max Memory Used: 30 MB


My Code:-



import time
import boto3
import stomp

kinesis_client = boto3.client('kinesis')


class Listener(stomp.ConnectionListener):
msg_list =
def on_error(self, headers, message):
print('received an error "%s"' % message)

def on_message(self, headers, message):
print('received a message "%s"' % message)
kinesis_client.put_record(
StreamName='Purchasing',
Data=u'{}rn'.format(message).encode('utf-8'),
PartitionKey='0'
)


def lambda_handler(event, context):
conn = stomp.Connection(host_and_ports=[('b-4714-4441-8166-47aae158281a-1.mq.eu-central-1.amazonaws.com', 8162)])
lst = Listener()
conn.set_listener('Listener', Listener())
conn.start()
conn.connect(login='test_mq', passcode='test_mq')
conn.subscribe(destination='/queue/Purchasing', id='b-4714-4441-8166-47aae158281a', ack='auto')
message = lst.msg_list
print('Waiting for messages "%s"' % message)
time.sleep(10)
conn.disconnect()
return ''


I am not sure why my message is not showing up in my output,instead it always shows up "Response: null".







python python-2.7 stomp amazon-mq






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 11:08

























asked Nov 20 '18 at 14:35







user10664125




















  • Please post your code as text, not a screenshot. We might need to copy and paste your code to our own text editors to reproduce your problem, and we can't do that from a graphic.

    – cdarke
    Nov 20 '18 at 14:46











  • @cdarke I have attached the code

    – user10664125
    Nov 20 '18 at 14:49



















  • Please post your code as text, not a screenshot. We might need to copy and paste your code to our own text editors to reproduce your problem, and we can't do that from a graphic.

    – cdarke
    Nov 20 '18 at 14:46











  • @cdarke I have attached the code

    – user10664125
    Nov 20 '18 at 14:49

















Please post your code as text, not a screenshot. We might need to copy and paste your code to our own text editors to reproduce your problem, and we can't do that from a graphic.

– cdarke
Nov 20 '18 at 14:46





Please post your code as text, not a screenshot. We might need to copy and paste your code to our own text editors to reproduce your problem, and we can't do that from a graphic.

– cdarke
Nov 20 '18 at 14:46













@cdarke I have attached the code

– user10664125
Nov 20 '18 at 14:49





@cdarke I have attached the code

– user10664125
Nov 20 '18 at 14:49












1 Answer
1






active

oldest

votes


















1














EDIT: As pointed by @Petesh, the issue comes from stompy(external library), which hasn't been ported to Python3.



If you check the source code, you can find this:



except socket.timeout, exc:


which is invalid syntax for python3+



If you run your Lambdas in python3.6/3.7 environment, the syntax is invalid.



The issue might go away if you choose python 2.7, but you will also have to adjust your code, libraries, etc.






share|improve this answer


























  • Can you clarify that the issue is with the stompy module, which has not been ported to python3 - it's not clear from your answer that this is what's the trigger of the issue.

    – Petesh
    Nov 20 '18 at 15:11











  • Done, good catch and thanks.

    – AlexK
    Nov 20 '18 at 15:14











  • @AlexK.. Thank you.. What adjustments I need to do to my code if I choose python 2.7. Moreover, How or where can I get python3+ stompy libraries

    – user10664125
    Nov 20 '18 at 15:39













  • @AlexK.. Also I have updated the error logs for python 2.7

    – user10664125
    Nov 20 '18 at 15:44











  • This pypi.org/project/stomp.py/#description looks like a alternative for python 3

    – AlexK
    Nov 20 '18 at 15:45











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395336%2faws-syntax-error-in-module-invalid-syntax%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown
























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














EDIT: As pointed by @Petesh, the issue comes from stompy(external library), which hasn't been ported to Python3.



If you check the source code, you can find this:



except socket.timeout, exc:


which is invalid syntax for python3+



If you run your Lambdas in python3.6/3.7 environment, the syntax is invalid.



The issue might go away if you choose python 2.7, but you will also have to adjust your code, libraries, etc.






share|improve this answer


























  • Can you clarify that the issue is with the stompy module, which has not been ported to python3 - it's not clear from your answer that this is what's the trigger of the issue.

    – Petesh
    Nov 20 '18 at 15:11











  • Done, good catch and thanks.

    – AlexK
    Nov 20 '18 at 15:14











  • @AlexK.. Thank you.. What adjustments I need to do to my code if I choose python 2.7. Moreover, How or where can I get python3+ stompy libraries

    – user10664125
    Nov 20 '18 at 15:39













  • @AlexK.. Also I have updated the error logs for python 2.7

    – user10664125
    Nov 20 '18 at 15:44











  • This pypi.org/project/stomp.py/#description looks like a alternative for python 3

    – AlexK
    Nov 20 '18 at 15:45
















1














EDIT: As pointed by @Petesh, the issue comes from stompy(external library), which hasn't been ported to Python3.



If you check the source code, you can find this:



except socket.timeout, exc:


which is invalid syntax for python3+



If you run your Lambdas in python3.6/3.7 environment, the syntax is invalid.



The issue might go away if you choose python 2.7, but you will also have to adjust your code, libraries, etc.






share|improve this answer


























  • Can you clarify that the issue is with the stompy module, which has not been ported to python3 - it's not clear from your answer that this is what's the trigger of the issue.

    – Petesh
    Nov 20 '18 at 15:11











  • Done, good catch and thanks.

    – AlexK
    Nov 20 '18 at 15:14











  • @AlexK.. Thank you.. What adjustments I need to do to my code if I choose python 2.7. Moreover, How or where can I get python3+ stompy libraries

    – user10664125
    Nov 20 '18 at 15:39













  • @AlexK.. Also I have updated the error logs for python 2.7

    – user10664125
    Nov 20 '18 at 15:44











  • This pypi.org/project/stomp.py/#description looks like a alternative for python 3

    – AlexK
    Nov 20 '18 at 15:45














1












1








1







EDIT: As pointed by @Petesh, the issue comes from stompy(external library), which hasn't been ported to Python3.



If you check the source code, you can find this:



except socket.timeout, exc:


which is invalid syntax for python3+



If you run your Lambdas in python3.6/3.7 environment, the syntax is invalid.



The issue might go away if you choose python 2.7, but you will also have to adjust your code, libraries, etc.






share|improve this answer















EDIT: As pointed by @Petesh, the issue comes from stompy(external library), which hasn't been ported to Python3.



If you check the source code, you can find this:



except socket.timeout, exc:


which is invalid syntax for python3+



If you run your Lambdas in python3.6/3.7 environment, the syntax is invalid.



The issue might go away if you choose python 2.7, but you will also have to adjust your code, libraries, etc.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 15:13

























answered Nov 20 '18 at 14:53









AlexKAlexK

869513




869513













  • Can you clarify that the issue is with the stompy module, which has not been ported to python3 - it's not clear from your answer that this is what's the trigger of the issue.

    – Petesh
    Nov 20 '18 at 15:11











  • Done, good catch and thanks.

    – AlexK
    Nov 20 '18 at 15:14











  • @AlexK.. Thank you.. What adjustments I need to do to my code if I choose python 2.7. Moreover, How or where can I get python3+ stompy libraries

    – user10664125
    Nov 20 '18 at 15:39













  • @AlexK.. Also I have updated the error logs for python 2.7

    – user10664125
    Nov 20 '18 at 15:44











  • This pypi.org/project/stomp.py/#description looks like a alternative for python 3

    – AlexK
    Nov 20 '18 at 15:45



















  • Can you clarify that the issue is with the stompy module, which has not been ported to python3 - it's not clear from your answer that this is what's the trigger of the issue.

    – Petesh
    Nov 20 '18 at 15:11











  • Done, good catch and thanks.

    – AlexK
    Nov 20 '18 at 15:14











  • @AlexK.. Thank you.. What adjustments I need to do to my code if I choose python 2.7. Moreover, How or where can I get python3+ stompy libraries

    – user10664125
    Nov 20 '18 at 15:39













  • @AlexK.. Also I have updated the error logs for python 2.7

    – user10664125
    Nov 20 '18 at 15:44











  • This pypi.org/project/stomp.py/#description looks like a alternative for python 3

    – AlexK
    Nov 20 '18 at 15:45

















Can you clarify that the issue is with the stompy module, which has not been ported to python3 - it's not clear from your answer that this is what's the trigger of the issue.

– Petesh
Nov 20 '18 at 15:11





Can you clarify that the issue is with the stompy module, which has not been ported to python3 - it's not clear from your answer that this is what's the trigger of the issue.

– Petesh
Nov 20 '18 at 15:11













Done, good catch and thanks.

– AlexK
Nov 20 '18 at 15:14





Done, good catch and thanks.

– AlexK
Nov 20 '18 at 15:14













@AlexK.. Thank you.. What adjustments I need to do to my code if I choose python 2.7. Moreover, How or where can I get python3+ stompy libraries

– user10664125
Nov 20 '18 at 15:39







@AlexK.. Thank you.. What adjustments I need to do to my code if I choose python 2.7. Moreover, How or where can I get python3+ stompy libraries

– user10664125
Nov 20 '18 at 15:39















@AlexK.. Also I have updated the error logs for python 2.7

– user10664125
Nov 20 '18 at 15:44





@AlexK.. Also I have updated the error logs for python 2.7

– user10664125
Nov 20 '18 at 15:44













This pypi.org/project/stomp.py/#description looks like a alternative for python 3

– AlexK
Nov 20 '18 at 15:45





This pypi.org/project/stomp.py/#description looks like a alternative for python 3

– AlexK
Nov 20 '18 at 15:45




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395336%2faws-syntax-error-in-module-invalid-syntax%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents