Mmap

import queue
import mmap

mapfile = '.malloc.mmap'

with open(mapfile, 'wb') as f :
    f.write(b'\x00')

q = queue.Queue()
n = 0
with open(mapfile, 'r+b') as f :
    mm = mmap.mmap(f.fileno(), 0)
    while True :
        mm.seek(0)
        flag = mm.readline()
        if flag == b'\x01' :
            n += 1
            q.put(n)
            mm[:] = b'\x00'
        else :
            if not q.empty() :
                print(q.get())
import os
import mmap

mapfile = '.malloc.mmap'

if os.path.isfile(mapfile) :
    with open(mapfile, 'r+b') as f :
        mm = mmap.mmap(f.fileno(), 0)
        mm[:] = b'\x01'

Daiphys is a professional-service company for research and development of leading-edge technologies in physics and engineering.
Get started accelerating your business through our deep expertise in R&D with AI, quantum computing, and space development; please get in touch with Daiphys today!

Name*


Email*


Message*


* Indicates required field

Daiphys Technologies LLC - https://www.daiphys.com/

  • Last modified: 2022/12/02 17:14
  • by Daiphys