Skip to content

Commit 472acd6

Browse files
Add initial configuration files for Python threading and debugging
1 parent 844f547 commit 472acd6

3 files changed

Lines changed: 119 additions & 0 deletions

File tree

.vscode/import threading.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import threading
2+
import time
3+
4+
def createAndRunTask(name: str, delay: float, action):
5+
"""Create a background task that waits `delay` seconds then runs `action`.
6+
7+
Returns the Thread object.
8+
"""
9+
10+
def wrapper():
11+
time.sleep(delay)
12+
try:
13+
action()
14+
except Exception as e:
15+
print(f"Task '{name}' raised: {e}")
16+
17+
t = threading.Thread(target=wrapper, name=name, daemon=True)
18+
t.start()
19+
return t
20+
21+
if __name__ == '__main__':
22+
# example usage
23+
def my_action():
24+
print('Task executed')
25+
26+
task = createAndRunTask('example', 1.0, my_action)
27+
task.join(timeout=2.0)

.vscode/launch.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Python Debugger: Current File",
5+
"type": "debugpy",
6+
"request": "launch",
7+
"program": "${file}",
8+
"console": "integratedTerminal"
9+
},
10+
{
11+
"name": "Attach",
12+
"port": 9229,
13+
"request": "attach",
14+
"skipFiles": [
15+
"<node_internals>/**"
16+
],
17+
"type": "node"
18+
},
19+
{
20+
"name": "Launch Chrome",
21+
"request": "launch",
22+
"type": "chrome",
23+
"url": "http://localhost:8080",
24+
"webRoot": "${workspaceFolder}"
25+
},
26+
{
27+
"type": "msedge",
28+
"name": "Launch Microsoft Edge",
29+
"request": "launch",
30+
"runtimeArgs": [
31+
"--remote-debugging-port=9222"
32+
],
33+
"url": "c:\\Users\\cbavi\\.vscode-insiders\\extensions\\ms-edgedevtools.vscode-edge-devtools-2.1.10\\out\\startpage\\index.html", // Provide your project's url to finish configuring
34+
"presentation": {
35+
"hidden": true
36+
}
37+
},
38+
{
39+
"type": "msedge",
40+
"name": "Launch Microsoft Edge in headless mode",
41+
"request": "launch",
42+
"runtimeArgs": [
43+
"--headless",
44+
"--remote-debugging-port=9222"
45+
],
46+
"url": "c:\\Users\\cbavi\\.vscode-insiders\\extensions\\ms-edgedevtools.vscode-edge-devtools-2.1.10\\out\\startpage\\index.html", // Provide your project's url to finish configuring
47+
"presentation": {
48+
"hidden": true
49+
}
50+
},
51+
{
52+
"type": "vscode-edge-devtools.debug",
53+
"name": "Open Edge DevTools",
54+
"request": "attach",
55+
"url": "c:\\Users\\cbavi\\.vscode-insiders\\extensions\\ms-edgedevtools.vscode-edge-devtools-2.1.10\\out\\startpage\\index.html", // Provide your project's url to finish configuring
56+
"presentation": {
57+
"hidden": true
58+
}
59+
}
60+
],
61+
"compounds": [
62+
{
63+
"name": "Launch Edge Headless and attach DevTools",
64+
"configurations": [
65+
"Launch Microsoft Edge in headless mode",
66+
"Open Edge DevTools"
67+
]
68+
},
69+
{
70+
"name": "Launch Edge and attach DevTools",
71+
"configurations": [
72+
"Launch Microsoft Edge",
73+
"Open Edge DevTools"
74+
]
75+
}
76+
]
77+
}

.vscode/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"python-envs.defaultEnvManager": "ms-python.python:system",
3+
"python.testing.unittestArgs": [
4+
"-v",
5+
"-s",
6+
"./PackageAssets",
7+
"-p",
8+
"*test.py"
9+
],
10+
"python.testing.pytestEnabled": true,
11+
"python.testing.unittestEnabled": false,
12+
"python.testing.pytestArgs": [
13+
"."
14+
]
15+
}

0 commit comments

Comments
 (0)