jmcnamara / XlsxWriter

A Python module for creating Excel XLSX files.
https://xlsxwriter.readthedocs.io
BSD 2-Clause "Simplified" License
3.61k stars 630 forks source link

Not enough quota is available to process this command #186

Closed mgrazebrook closed 9 years ago

mgrazebrook commented 9 years ago

Message:

Traceback (most recent call last): File "C:\Python33\Lib\SITE-P~1\PYTHON~2\pywin\framework\editor\document.py", line 321, in Run win32api.PostMessage(self.hwnd, MSG_CHECK_EXTERNAL_FILE, 0, 0) pywintypes.error: (1816, 'PostMessage', 'Not enough quota is available to process this command.') win32ui.error: Run() virtual handler (<bound method FileWatchingThread.Run of <pywin.framework.editor.document.FileWatchingThread object at 0x038C72D0>>) raised an exception

Possibly relevant: [http://stackoverflow.com/questions/12584619/mysterious-not-enough-quota-is-available-to-process-this-command-in-winrt-port]

This suggests it's a queue overflow.

I appear to have fixed this in my own copy by amending document.py, method FileWatchingThread.Run

            if rc == win32event.WAIT_OBJECT_0:
                time.sleep(1e-3)

This is a bit hacky, there's probably a more proncipled way to fix it.

jmcnamara commented 9 years ago

Hi,

It is hard to see how this relates to XlsxWriter since the module isn't mentioned anywhere in the bug report or traceback.

If it somehow relates to an action at a distance and is caused by running out of memory then try setting constant_memory mode in the constructor:

workbook = xlsxwriter.Workbook(filename, {'constant_memory': True})

Let me know if this fixes it. If not then submit a small but complete working program that demonstrates the issue.

Regards,

John.

mgrazebrook commented 9 years ago

I cannot reproduce the problem, even after reverting my changes (in contrast, it was reproducable yesterday on the same code base ...). The following notes may help if someone encounters the problem again; intermittent problems are hard to kill!

I ran the code from within PythonWin and the message seems to relate to PythonWin.

The code uses the mysql module and returns about 7k rows of around 500 bytes => memory shouldn't be an issue. (it consists of a main query and a sub query)

Using constant_memory, the program works, but as I can't make it fail any more, I learn little.

Immediately prior to failing, the program printed 5360 rows to the pythonwin Interactive Window, despite there being no code of mine to print it. Row formatting matches the Excel data, not the data I put into xlswriter: my source data has datetimes and the printed rows have the numbers which underly Excel datetimes. When operating correctly (e.g. with the sleep() as described above), no rows are printed to the terminal. The main query returns 6330 rows.

Conjecture: Something went wrong in xlswriter (not necessarily a library problem), xlswriter dumped the rows as a diagnostic and this somehow overloaded Windows' ability to process requests to update the GUI. The Windows exception may have overridden a perfectly good error message from xlswriter. (A problem with this: the sleep fix doesn't seem relevant if the print is never triggered??)

PS: John, I'm impressed by your swift response.