a
    ï‚jR  ã                
   @   s„  d Z ddlZddlZddlZddlZej dd¡ ddlZg Z	d2dd„Z
ej ¡ r`ejjdd�ndZ�z¶ej ¡ r|ej ¡  ed	ƒ e
d
e ¡ du ƒ e
dej ¡ ƒ e ejjdd�¡Ze
de d¡e ¡ kde d¡› �ƒ edƒ e ¡ Zejje ee ¡ dœ¡dd� e
de ¡ du de› �ƒ edƒ e ¡ d Zejje ee ¡ dœ¡dd� e
de ¡ du dƒ edƒ ejje e ¡ e ¡ dœ¡dd� e
de ¡ du ƒ edƒ ejje e ¡ d e ¡ ej d dœ¡dd� e
de ¡ du dej› d �ƒ ed!ƒ e ejjdd�¡d" Ze d#¡ e ¡  e ejjdd�¡d" Ze
d$eekee d%›d �ƒ e  ¡  e
d&ej ¡  ƒ ed'ƒ ejjd(dd� e
d)e ¡ du ƒ e  ¡  ed*ƒ e
d+ejd,ej! kej› d-ej!› d �ƒ W ej ¡ �rej ¡  edu�rPejjedd� n2ej ¡ �r4ej ¡  edu�rNejjedd� 0 ed.e	�s^d/nd0e	› � ƒ e "e	�rzd1nd¡ dS )3a„  Only one live maker may run at a time.

On 2026-08-16 a relaunch happened before the previous process exited. Two makers
ran against one account, each posted its own orders, and every leg ended up with
two resting. The duplicate guard could not recover: it cancels BOTH orders on a
leg and the other process re-posted immediately, so resting orders climbed
54 -> 81 while the guard fired continuously.

Every other safety in mm_maker_live assumes a single writer -- the duplicate
guard, the resting-over-cap abort, the post budget, the ratchet floors held in
state. This test holds the assumption that makes them valid.

No network, no orders.
é    NzE:\soccer\mainÚ c                 C   s>   t d|rdnd› d| › |r"d| nd› �ƒ |s:t | ¡ d S )Nz  [ÚpassZFAILz] z  r   )ÚprintÚfailsÚappend)ZlabelZcondZextra© r   ú&E:\soccer\main\test_single_instance.pyÚcheck   s    ,r	   zutf-8)Úencodingz === a free lock can be taken ===zacquire on a clean slateTzlock file writtenzrecords our pidÚpidzpid z>
=== a live lock held by ANOTHER pid blocks a second maker ===)r   Ú	heartbeatz*second instance refused while holder livesFzholder pid z1
=== a lock held by a DEAD pid does not block ===i?B z-dead holder ignored despite a fresh heartbeatz,a force-killed maker never releases its lockz5
=== our own pid is never blocked by our own lock ===zsame pid may re-acquirez9
=== a STALE lock is taken over, not honoured forever ===iŸ† é   zstale lock does not blockzstale after Úsz3
=== heartbeat keeps it fresh, release frees it ===r   gš™™™™™ñ?zheartbeat advancesz.1fzrelease removes the lockz:
=== a corrupt lock file must not wedge the maker shut ===znot json at allzgarbage lock is ignoredz4
=== the stale window covers several poll cycles ===zstale window > 2 pollsé   z
s vs poll Ú
z
ALL PASSEDz
FAILURES: é   )r   )#Ú__doc__ZjsonÚosÚsysÚtimeÚpathÚinsertZmm_maker_liveZMLr   r	   Z	LOCK_FILEÚexistsÚ	read_textZsavedÚunlinkr   Zlock_acquireÚloadsÚdÚgetÚgetpidÚgetppidÚotherZ
write_textÚdumpsZdeadZLOCK_STALE_SZbeforeÚsleepZ	lock_beatZafterZlock_releaseZ	POLL_SECSÚexitr   r   r   r   Ú<module>   sœ   


&ÿÿÿ
þÿþ

ÿÿþÿ
ÿ

ý

