FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PythonLearning/73.MultiprocessingInPythonPart1.py at Pythontuts · aditya0035/PythonLearning · GitHub
aditya0035
/
PythonLearning
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PythonLearning
/
73.MultiprocessingInPythonPart1.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (30 loc) · 1.08 KB
Breadcrumbs
PythonLearning
/
73.MultiprocessingInPythonPart1.py
Copy path
File metadata and controls
36 lines (30 loc) · 1.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Like Threading we can create different process bt the issue with process is that we can't share a resource b/w them
also when we create a process it will run separately under a different thread
To Create Multiprocessing we have to import Multiprocessing Module
"""
from
multiprocessing
import
Process
from
datetime
import
datetime
def
ask_user
():
user_input
=
input
(
"Enter Your Name"
)
greet
=
f'Hello
{
user_input
}
'
print
(
greet
)
def
Complex_Calculation
():
print
(
"Starting Calculation"
)
x
=
[
x
**
2
for
x
in
range
(
10000000
)]
print
(
"Ending Calculation"
)
print
(
__name__
)
if
__name__
==
'__main__'
:
print
(
__name__
)
proces1
=
Process
(
target
=
Complex_Calculation
)
proces1
.
start
()
ask_user
()
proces1
.
join
()
"""
Here we will get error as we are tryong to access resource termial which is running in main thread
So from this we can say that process does not share the resource easily
"""
"""
From This we can conclude that for waiting use multiThreading and process when no resource sharing required and need to
run thing concurrently
"""
Back
|
FazBrowse Home
|
New Git URL