Thread not working in Atom?


#1

Hello, I am having a very strange issue. I am working with a weather API with Python. I have a request that gets my weather.temperature every 10 minutes but the issue is weird in Atom. The thread runs only the first time, then it would seem that it doesn’t get the information. So my question is actually,what is wrong? And don’t tell me it is just because each time it prints on the same spot and the strings don’t stack but it actually works (joking). I have tried that in Visual Studio and the thread works also the API request.
Thank you for your answers, I would appreciate some suggestions on fixing that!


#2

Atom doesn’t execute Python code, so I’m not sure how what you’re describing could even work the first time. Can you give some more details around what it is you’re doing and what it is you expect Atom to do? Perhaps you have some community packages installed that aren’t doing what you expect them to do?


#3

I have python package, I have this piece of code and I want my thread to run over X time, the problem is that in Atom it runs only the first time. And can I get an explanation on why Atom doesn’t run Python and actually how come? Sorry if the question is stupid I am new to Atom and Python.

import requests
import json
import threading

def main():
li = [“City1”, “City2”, “City3”]
response = requests.get(MyApi)
weather = response.json()
print("The weather for ", weather[‘name’])
print("The temperature is ", weather[‘main’][‘temp’])
threading.Timer(10, main).start()

if name == ‘main’:
main()


#4

Because Atom is designed to be a text editor, not an IDE. For a bit of background on what the differences are and why an editor might be better than an IDE for some uses, see the FAQ:

If you’re running into a problem with a specific package, you may want to contact the maintainers of that package. The Atom FAQ has information on how to contact the maintainers of any Atom community package or theme.

My personal recommendation though is to either run your Python script from the command line outside of Atom or perhaps take a look at some Python IDEs for your development environment.


#5

Thank you! And sorry for the lack of information from my side. Will get to the reading!