`os.mkfifo` is not supported

Aperta
#999 4 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

Inizia in fake_os.py, in FakeOsModule, e confronta la gestione esistente di os.pipe(). Determina se mkfifo debba creare soltanto una voce nel filesystem oppure utilizzare un oggetto FakeFIFO con comportamenti distinti per apertura, lettura e scrittura; il lavoro è completato quando os.mkfifo è supportato solo su Unix senza creare una FIFO reale, incluse le opzioni e gli errori documentati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Is your feature request related to a problem? Please describe.
No implementation for os.mkfifo() (Unix only).

Describe the solution you'd like
Add implementation so that real FIFOs don't get created in the filesystem.

Describe alternatives you've considered
Currently requires additional mocking.

Need to add something like the following to FakeOsModule in fake_os.py:

    def mkfifo(
        self,
        path: AnyStr,
        mode: int = PERM_DEF_FILE,
        *,
        dir_fd: Optional[int] = None,
    ) -> None:
        """Create a FIFO (a named pipe) named 'path'.

        Args:
            path: (str) Name of the file to create.
            mode: (int) Permissions to use and type of file to be created.
                Default permissions are 0o666.  The umask is applied to this
                mode.
            dir_fd: If not `None`, the file descriptor of a directory,
                with `path` being relative to this directory.

        Raises:
            OSError: If called with unsupported options or the file can not be
                created.
        """
        if self.filesystem.is_windows_fs:
            raise AttributeError("module 'os' has no attribute 'mkfifo'")

        path = self._path_with_dir_fd(path, self.mkfifo, dir_fd)
        head, tail = self.path.split(path)
        if not tail:
            if self.filesystem.exists(head, check_link=True):
                self.filesystem.raise_os_error(errno.EEXIST, path)
            self.filesystem.raise_os_error(errno.ENOENT, path)
        if tail in (matching_string(tail, "."), matching_string(tail, "..")):
            self.filesystem.raise_os_error(errno.ENOENT, path)
        if self.filesystem.exists(path, check_link=True):
            self.filesystem.raise_os_error(errno.EEXIST, path)
        self.filesystem.add_object(
            head,
            FakeFile(tail, mode & ~self.filesystem.umask, filesystem=self.filesystem),
        )

However, in using a regular file object in the example above, this doesn't simulate the semantics of a FIFO. Could also take inspiration from os.pipe(), except os.mkfifo() doesn't actually open fds, it just creates the entry in the filesystem - maybe create a FakeFIFO object in the filesystem which would then presumably need to handle open/read/write differently.

Lingua principale
Python
Stelle
756
Fork
111
Merge medio
3g 21h
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytest-dev/pyfakefs

Tutte le issue di pytest-dev/pyfakefs

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.