A for-range over a channel that's never closed leaks the receiver. Why a fixed number of receives is safe, why a range isn't, and how to catch it with Go 1.27's leak profile.
A for-range over a channel that's never closed leaks the receiver. Why a fixed number of receives is safe, why a range isn't, and how to catch it with Go 1.27's leak profile.
A for-range over a channel that's never closed leaks the receiver. Why a fixed number of receives is safe, why a range isn't, and how to catch it with Go 1.27's leak profile.
Notes on Go's accepted goroutine leak profile and how it reuses the GC to find them.
Notes on Go's accepted goroutine leak profile and how it reuses the GC to find them.
michaelpj:
OK, this is supposed to be clear from loggerExampleConcurrently. I’ll see if I can clarify that.
In that example you do the modification inside the fork, so it wasn’t obvious to me whether the modification would be visible if you did it the other way around.
Ah yes, this example needs improving, thanks!
michaelpj:
What’s the use of having thread local state that…
OK, this is supposed to be clear from loggerExampleConcurrently. I’ll see if I can clarify that.
In that example you do the modification inside the fork, so it wasn’t obvious to me whether the modification would be visible if you did it the other way around.
How would the behaviour differ? Do you mean that
InheritedThreadLocalIORefcould be modified within a thread like an…
michaelpj:
Sounds great. Not very clear from the article that that’s the intended semantics though!
OK, this is supposed to be clear from loggerExampleConcurrently. I’ll see if I can clarify that.
michaelpj:
So I guess my API question is whether this is best thought of as a new kind of thread-local variable. Is there anything that you can do with your
IOScopedRefAPI that you couldn’t…
A Go closure holds a live reference to whatever it captures, not a snapshot. Real examples of where this trips people up, and how to keep it boring.
A Go closure holds a live reference to whatever it captures, not a snapshot. Real examples of where this trips people up, and how to keep it boring.
Why your mutex wrapper should accept a closure for mutation instead of a plain value, with examples from the standard library and Tailscale.
How Go 1.20's WithCancelCause and Go 1.21's WithTimeoutCause let you attach a reason to context cancellation, plus a gotcha with manual cancel and the stdlib pattern that covers every path.
How Python and Kotlin provide structured concurrency out of the box while Go achieves the same patterns explicitly using errgroup, WaitGroup, and context.
Prevent goroutine leaks caused by early returns with unbuffered channels. Learn buffering, draining, errgroup patterns, and goleak testing.
Prevent dangerous struct copies with noCopy sentinel and go vet's copylock checker. Protect mutexes and sync primitives from value copies.
Control goroutine concurrency with buffered channels as semaphores. Prevent resource exhaustion with backpressure patterns in Go workers.
Gracefully shutdown Python's ThreadingTCPServer with signal handlers for SIGINT, SIGTERM handling and client notification on server shutdown.
Build a pausable socket server with Python's socketserver module using threading for intermittent request handling and background tasks.
Display progress bars for concurrent Python tasks using tqdm with ThreadPoolExecutor and as_completed for real-time execution monitoring.
Process large CSV files without OOM errors by streaming content line-by-line with HTTPX and concurrent.futures for parallel processing.
Speed up Django bulk operations with ProcessPoolExecutor while preserving signals and hooks that bulk_create/bulk_update bypass.
Control concurrent async requests with Python asyncio.Semaphore to respect rate limits and prevent overwhelming APIs or services.
Integrate tqdm progress bars with multiprocessing.imap_unordered for visual feedback on parallel task execution across worker processes.
Test Python infinite loops safely using daemon threads with timeouts, allowing tests to complete without hanging or blocking execution.
Master Python's concurrent.futures module for easy threading and multiprocessing. Learn ThreadPoolExecutor and ProcessPoolExecutor with examples.