3

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)
Balázs Patai
  • 105
  • 1
  • 9
  • 3
    A simple way is to run one of the scripts outside visual studio code... You can do that directly from a command line terminal/console or if you prefere from idle. – Serge Ballesta Sep 29 '21 at 09:40

3 Answers3

3

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

Balázs Patai
  • 105
  • 1
  • 9
2

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)

andber1
  • 131
  • 10
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 29 '21 at 15:32
1

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.

Al Martins
  • 431
  • 5
  • 13