Balázs Patai
Balázs Patai

Reputation: 105

Running two python file at the same time in visual studio code

i have two files, and i want to run both. The first one is basically asking down the prices of stocks and writes them to a database, and the second one using python dash to create a webpage. This webpage is showing the data in real time from the database which is constantly refreshes. I tried to use threading but it does not work, because the two files basically function as two infinite while loop. How should i solve this problem? The two functions im having problem with are dataMiningScript= fd.financeData(database,1600) and if name == "main": app.run_server(debug=True)

app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
database=db.dataBase()
homepage=hp.homepage(database)
homepage.timeUpdateCallback(app)
homepage.gaugeRefreshCallback(app)
dataMiningScript= fd.financeData(database,1600)

app.layout = homepage.layoutMaker()



if __name__ == "__main__":
   app.run_server(debug=True)

Upvotes: 3

Views: 4573

Answers (3)

Al Martins
Al Martins

Reputation: 436

Helpful discussion here: run multiple python scripts at the same time.

Covers the question posted at the title fairly well.

On new window I managed to run the necessary code by typing a command. Run Python File button remains tied too original window.

Upvotes: 1

Balázs Patai
Balázs Patai

Reputation: 105

For some reason i cannot run two python programs at the same time in Visual Studio Code, but i managed to solve this problem with the solution of the first commenter:

I opened terminal and search my .py program. Then i write

python3 xy.py

Upvotes: 3

andber1
andber1

Reputation: 194

You can just create two terminals in visual studio code to run both files (see here). Or you can create a simple shell script which starts both programs (start a program in the background with a '&' at the end of the command line)

Upvotes: 2

Related Questions