Skip to content

Multiprocessing and running frozen on Windows #33

@1marc1

Description

@1marc1

I recently upgraded my environment, along with it I upgraded from logger_tt 1.7.3 to 1.7.4. I found that my application crashes when I run it frozen on Windows. The crash happens as soon as my code calls pool.map(). I then get numerous messages on the screen, saying that the file C:\Program Files\My Program\logs\log.txt does not exist.

I did a lot of digging around and found the reference to logs/log.txt in my configuration file:

{
  "version": 1,
  "disable_existing_loggers": false,
  "formatters": {
    "simple": {
      "format": "%(asctime)s %(name)-8s %(levelname)-8s %(processName)-10s %(message)s"
    },
    "brief": {
      "format": "[%(asctime)s] %(levelname)s: %(message)s",
      "datefmt": "%Y-%m-%d %H:%M:%S"
    }
  },

  "handlers": {
    "console": {
      "class": "logging.StreamHandler",
      "level": "INFO",
      "formatter": "brief",
      "stream": "ext://sys.stdout"
    },

    "error_file_handler": {
      "class": "logging.handlers.TimedRotatingFileHandler",
      "level": "DEBUG",
      "formatter": "simple",
      "filename": "logs/log.txt",
      "backupCount": 3,
      "encoding": "utf8",
      "when": "midnight"
    }
  },

  "loggers": {
    "urllib3": {
      "level": "ERROR",
      "handlers": ["error_file_handler"],
      "propagate": false
    }
  },

  "root": {
    "level": "DEBUG",
    "handlers": ["error_file_handler"]
  },

  "logger_tt": {
    "suppress": ["exchangelib"]
  }
}

My program sets up the logging as follows: setup_logging(config_path=_jsonfile, log_path=_logfile, use_multiprocessing=True), whereby _jsonfile references the configuration file listed above and _logfile references a user-writable location to keep the log file.

When I manually create the C:\Program Files\My Program\logs directory and run my program as Administrator, I don't run into the problem. I then notice that a "log.txt" file is created in that directory with a size of 0 bytes. I attribute this to the fact that an ordinary user does not have write access inside the C:\Program Files directory structure, but an administrator does.

When I revert back to logger_tt 1.7.3, using the same config file, I don't experience this issue. Can someone look into this to work out what has changed between versions that causes this behaviour and perhaps update the code so this doesn't happen?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions