This project has moved. For the latest updates, please go here.


Code examples in worker role should be moved above main


The template for has convenient sample code that you can call from the worker role, except it won't work if you call it from the main loop, because the example functions are defined below.

Given that everything else in the is plug & play (insert your creds here and off you go), then I would like to be able to use the example functions without having to move them around.


Zooba wrote May 20, 2014 at 9:29 PM

I don't intend them to be usable. The only reason they aren't entirely in comments is because they are less readable without syntax highlighting.

If, when we triage this, we decide it is worth doing, I'd rather change the current if __name__ == '__main__' block into a main() function that is called from after the examples are defined.

huguesv wrote May 21, 2014 at 12:55 AM

I probably lost an hour due to this today. I was too optimistic and decided to go directly with the publish to azure and try to run it there. Couldn't understand what was failing. I figured it was trouble with the publishing, not with the code in which looked fine. Tried to run in the emulator, again, couldn't figure out why my blob wasn't getting created. It's such a terrible debugging experience that we shouldn't mislead users into thinking that the code is useable when it's not. Finally I decided to run the Python project instead of the cloud service project, and found out that it couldn't call the example functions due to them being defined after the main loop. Extremely frustrating, I don't want any user to have to go through this.

Zooba wrote May 21, 2014 at 3:47 AM

Then maybe the answer is to not include the examples and just link to a doc page with them from the template?

huguesv wrote May 21, 2014 at 10:11 PM

One idea I had is to move all of the samples to a different file/module, maybe '' or something like that.
The user that doesn't care about them would have a clean to work with, and it's very easy to just delete
The user that wants to try out worker role can just fill in the credentials in and then from
import examples