Skip to content
This repository has been archived by the owner on Aug 13, 2020. It is now read-only.

web3 integration #96

Closed
AzielioTor opened this issue Apr 20, 2018 · 2 comments
Closed

web3 integration #96

AzielioTor opened this issue Apr 20, 2018 · 2 comments

Comments

@AzielioTor
Copy link

Hello Everyone!
My team and I are working on getting Calvin to interact with smartcontracts, but this requires the use of web3.py which can only be used on python3.x. As calvin is developed on python 2.x, what is the best way for us to try and integrate?

It feels like a daunting task to rewrite all of the web3 framework to work on python2. My other thought is calling python3 scripts and getting results with the use of:

from subprocess import call
result = call(“python3 python3code.py”)

Is this the best way to go about it or has someone else run into the python versioning issue before and found a more elegant way to resolve this?

Thanks everyone!
Aziel

@olaan
Copy link
Contributor

olaan commented Apr 22, 2018

Hey,

this is one way of doing it. Keep in mind that subprocess.call will block until the script has finished, so if you execute this from the main thread in the runtime, then the entire runtime will wait for it to finish. Note that this will only return the exit code from the python3 application. It is common to be interested in more than this, e.g. standard out and such, so you may want to use subprocess.Popen() instead.

Another way of doing it would be to have the python3 application running as a service and communicate with it using e.g. sockets or REST. For long-running jobs with communication going in both directions, sockets would probably be the preferred way.

On a side note, we are planning on moving over to python3, but there is as yet no set timeframe for it. I cannot promise it will be this year.

Cheers,

// Ola

@olaan
Copy link
Contributor

olaan commented Jul 2, 2018

I'm closing this issue now. If you have further questions, feel free to open a new one.

Cheers.

@olaan olaan closed this as completed Jul 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants