Sujet : Re: Process.start
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.pythonDate : 03. Sep 2024, 14:02:30
Autres entêtes
Organisation : Stefan Ram
Message-ID : <threads-20240903140046@ram.dialup.fu-berlin.de>
References : 1
marc nicole <
mk1853387@gmail.com> wrote or quoted:
Thanks for the reply, Here's the code I tested for the debug:
print("executed")
but neither "Hello World" or "Executed" are displayed in the console which
It shouldn't spit out "Executed" 'cause there's a lowercase
"e" in the mix. Talk about sweating the small stuff!
That 'if __name__ == "__main__"' jazz? It's barking up the wrong
tree here, just muddying the waters. I'd 86 that clause for now.
In your start() function call, you're rockin' "do_something()",
but the actual function's defined as "do_Something()" with a
capital "S". Python's all about that case sensitivity.
Dropping that "exit(0)" bomb right after firing up the process?
That's like bailing on a gnarly wave before you even catch it.
It might pull the plug on the main process before the kid process
has a chance to strut its stuff.
Those "ghello" and "fhello" functions? They're just chillin'
there, not pulling their weight!
Now the question, when to use Process/Multiprocess and when to use
Threading in Python?
When it comes to processes vs. threads, it's like choosing
between a burrito and a taco.
Use processes for those CPU-heavy tasks to get that real
parallel action across multiple cores, dodging Python's GIL
like it's rush hour on the 405.
Processes are also tougher than a two-dollar steak and perfect
for memory hogs.
On the flip side, threading's your go-to for I/O-bound tasks
where the GIL takes a breather during I/O ops, letting you
multitask like a boss. Threads are as light as a surfer's
board, play nice with shared memory, and are the bee's knees
for juggling a ton of tasks without breaking a sweat.