frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: Aiologic – GIL-powered* locking library for Python

https://github.com/x42005e1f/aiologic
1•x42005e1f•10h ago
Well, I guess better now than never.

Hello, Hacker News readers. My name is Ilya Egorov, and for the past year I have been developing a somewhat esoteric library for Python. The idea behind it is quite simple: primitives (such as locks) that work in different environments at the same time (for example, an asyncio thread and any other threads), one instance for everything (both async-aware and thread-aware/thread-safe), without complicating things for the user.

It all started sometime around 2022-2023, when I was writing a bridge between different messengers (APIs) on AnyIO for personal use. At the time, I wanted to achieve fairness in processing different chats, but part of the work was CPU-bound, and isolating it into separate synchronous threads would have led to noticeable overhead. The most logical thing that came to mind at that moment was to parallelize all asynchronous code, one "asynchronous" thread for each chat (nowadays, such ideas have been popularized with the advent of free-threading), in order to take advantage of preemptive multitasking. But how to synchronize and communicate between different tasks in different threads when none of the available asynchronous primitives are thread-safe? I did not like any of the workarounds known at the time, so I started writing my own.

In 2023, I tried various approaches to creating a universal lock, which I called an "atomic lock" (since I planned to implement other primitives I needed on top of it). The principle of operation is quite simple: each instance uses collections.deque as a token queue (lock owners; something very similar is used in the current implementation of aiologic.lowlevel.ThreadOnceLock) and threading.Lock to synchronize the internal logic. It seemed like everything was working, and I could have stopped there, but the latter bothered me. As long as my lock used threading.Lock, known for blocking event loops and thus causing timeout issues, there could be no question of its fairness. However, all I could achieve at that point was to define the lock recurrently (where the event loop blocking time decreased with increasing nesting but increased overhead for each call).

In the spring of 2024, after digging deep into atomic programming (especially lock-free and wait-free queues), it hit me that something similar could be implemented at the Python level. I did not decide to use effectively atomic operations right away, since almost no one had done so before me (the information available on them is very poor, and I had to research it all myself), but after seeing how reliable they are (they are even used in standard CPython tests, and free-threading fixes are also related to them), I created the first primitive that works without synchronization of internal logic. My worldview changed, and I went on to create other primitives, also without synchronization. A few months later, in August 2024, aiologic was born.

Now, a year later, the library is already quite well developed. It supports a wide variety of concurrency libraries, whether it is gevent or Trio, and everything with as many threads as you want. There are locks, semaphores, queues, and others. A brief description is somewhat humorous: "GIL-powered" but supports free-threading (in essence, this is about effectively atomic operations, which is very interesting on PyPy - see the classic benchmark); "locking" but almost never uses locks under the hood (except in some special cases). The development status is still alpha, but in my opinion, the reliability is quite high, as I constantly recheck the implementation with proactive bug fixing (see the overly detailed logs).

I hope you find my library interesting.

Are Apple Gift Cards Safe to Redeem?

https://daringfireball.net/linked/2025/12/17/are-apple-gift-cards-safe-to-redeem
1•tosh•21s ago•0 comments

Running a full voice stack (ASR –> LLM –> TTS) locally with Docker

https://www.docker.com/blog/develop-deploy-voice-ai-apps/
1•3Sophons•1m ago•1 comments

systemd v259 Released

https://github.com/systemd/systemd/releases/tag/v259
1•voxadam•2m ago•0 comments

Engineering dogmas it's time to retire

https://newsletter.manager.dev/p/5-engineering-dogmas-its-time-to
1•flail•3m ago•0 comments

Ask HN: How are you building a company-wide MCP strategy?

1•shouche•5m ago•1 comments

Hatred of Israel Caused Iran's Water Crisis

https://aish.com/hatred-of-israel-caused-irans-water-crisis/
1•mhb•6m ago•1 comments

Show HN: Physically Based Shading Dojo in WebGL2

https://gnikoloff.github.io/webgl-pbr-dojo/
1•georginikolov•6m ago•1 comments

Legal AI startups sell fear, not products

https://theredline.versionstory.com/p/why-cant-43b-in-legal-ai-investment
1•jpbryan•6m ago•0 comments

How to Win Titular Metagames

https://taylor.town/how-to-title
1•surprisetalk•7m ago•0 comments

Please Just Try Htmx

http://pleasejusttryhtmx.com/
2•iNic•8m ago•0 comments

Ask HN: How to manage inbound calls/ emails/ texts etc.

1•duckkg5•8m ago•1 comments

The collab way for creators to find work and get paid

https://the-fuse.app/
1•iCeGaming•9m ago•1 comments

How agent workloads change the shape of data systems

https://tonbo.io/blog/tonbo-manifesto
1•ethegwo•11m ago•0 comments

Free Live Streaming Platform for Developers with No Catches

https://www.red5.net/blog/free-live-streaming-platform-for-developers/
1•mondainx•11m ago•1 comments

Show HN: SHM – Telemetry for self-hosted apps (no user tracking)

https://github.com/btouchard/shm
1•benjy3379•13m ago•0 comments

1.5 TB of VRAM on Mac Studio – RDMA over Thunderbolt 5

https://www.jeffgeerling.com/blog/2025/15-tb-vram-on-mac-studio-rdma-over-thunderbolt-5
2•bonyt•15m ago•0 comments

Trump Media is merging with a nuclear fusion company

https://www.theverge.com/news/847159/trump-media-tae-technologies-merger-nuclear-fusion
2•trueduke•15m ago•0 comments

Pandemic Lockdowns Changed a Songbird's Beak

https://www.nytimes.com/2025/12/15/science/covid-ecology-anthropause-birds.html
1•danso•16m ago•1 comments

MEV is an execution design problem

1•shdwapp•18m ago•0 comments

Jensen Huang: Israel has become Nvidia's second home

https://en.globes.co.il/en/article-jensen-huang-israel-has-become-nvidias-second-home-1001529537
1•mhb•18m ago•0 comments

Show HN: Open-Source B2B SaaS Starter Kit (Go, Next.js, RBAC, Polar)

https://github.com/moasq/production-saas-starter
1•moh_quz•18m ago•0 comments

The Impact of Technical Blogging

https://writethatblog.substack.com/p/the-impact-of-technical-blogging
1•cyndunlop•19m ago•0 comments

An Engineer's Critique of Physicalism (Materialism)

https://arrno.substack.com/p/an-engineers-critique-of-physicalism
1•arrno•19m ago•1 comments

Closure of Operations in Computer Programming

https://deniskyashif.com/2025/12/18/closure-of-operations-in-computer-programming/
1•deniskyashif•20m ago•0 comments

The Mysterious Forces Steering Views on Hacker News

https://xn--gckvb8fzb.com/the-mysterious-forces-steering-views-on-hacker-news/
3•dxs•21m ago•1 comments

The 10 Most Mind-Blowing Discoveries About the Brain in 2025

https://www.scientificamerican.com/article/10-mind-blowing-brain-discoveries-from-2025/
1•dxs•22m ago•0 comments

Virtualizing Nvidia HGX B200 GPUs with Open Source

https://www.ubicloud.com/blog/virtualizing-nvidia-hgx-b200-gpus-with-open-source
16•ben_s•23m ago•0 comments

Programming Ruby 4 (The 6th edition of the PickAxe Book)

https://pragprog.com/titles/ruby6/programming-ruby-4-6th-edition/
1•Kerrick•23m ago•0 comments

Bill Gurley on the AI Era, 10 Days in China, and More [video]

https://www.youtube.com/watch?v=rjSesMsQTxk
1•gk1•25m ago•0 comments

The Rise of SQL:the second programming language everyone needs to know

https://spectrum.ieee.org/the-rise-of-sql
2•b-man•26m ago•0 comments