Skip to content

Commit 4b44454

Browse files
committed
adding cache_dir to AsyncPydf, removing 3.5 support
1 parent 94a15c5 commit 4b44454

File tree

6 files changed

+25
-24
lines changed

6 files changed

+25
-24
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: python
22
sudo: false
33

44
python:
5-
- '3.5'
65
- '3.6'
76
- 'nightly'
87

HISTORY.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,17 @@ History
55

66
v0.31.0 (2017-05-23)
77
....................
8-
* move to python 3.5 +
8+
* move to python 3.6 +
9+
* add ``async`` generation for roughly 10x speedup
10+
11+
v0.30.0
12+
.......
13+
14+
- uprev wkhtmltopdf from **0.12.2 (beta)** to **0.12.4**.
15+
- code cleanup
16+
- (this is the same as ``v0.3``, I made a mistake when versioning)
17+
18+
v0.21.0
19+
.......
20+
21+
- correct permissions on wkhtmltopdf binary.

README.rst

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pydf
22
====
33

44

5-
|Build Status| |codecov.io| |PyPI Status| |license|
5+
|BuildStatus| |codecov| |PyPI| |license|
66

77
PDF generation in python using
88
`wkhtmltopdf <http://wkhtmltopdf.org/>`__.
@@ -94,26 +94,11 @@ option
9494
Low level function to call wkhtmltopdf, arguments are added to
9595
wkhtmltopdf binary and passed to subprocess with not processing.
9696

97-
Changelog
98-
---------
99-
100-
0.30
101-
~~~~
102-
103-
- uprev wkhtmltopdf from **0.12.2 (beta)** to **0.12.4**.
104-
- code cleanup
105-
- (this is the same as ``v0.3``, I made a mistake when versioning)
106-
107-
0.21
108-
~~~~
109-
110-
- correct permissions on wkhtmltopdf binary.
111-
112-
.. |Build Status| image:: https://travis-ci.org/tutorcruncher/pydf.svg?branch=master
97+
.. |BuildStatus| image:: https://travis-ci.org/tutorcruncher/pydf.svg?branch=master
11398
:target: https://travis-ci.org/tutorcruncher/pydf
114-
.. |codecov.io| image:: https://codecov.io/github/tutorcruncher/pydf/coverage.svg?branch=master
99+
.. |codecov| image:: https://codecov.io/github/tutorcruncher/pydf/coverage.svg?branch=master
115100
:target: https://codecov.io/github/tutorcruncher/pydf?branch=master
116-
.. |PyPI Status| image:: https://img.shields.io/pypi/v/python-pdf.svg?style=flat
101+
.. |PyPI| image:: https://img.shields.io/pypi/v/python-pdf.svg?style=flat
117102
:target: https://pypi.python.org/pypi/python-pdf
118103
.. |license| image:: https://img.shields.io/pypi/l/python-pdf.svg
119104
:target: https://github.com/tutorcruncher/pydf

benchmark/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def go_sync():
19-
count = 20
19+
count = 10
2020
for i in range(count):
2121
pdf = generate_pdf(
2222
html,
@@ -53,7 +53,6 @@ async def gen(i_):
5353
zoom='1.25',
5454
margin_left='8mm',
5555
margin_right='8mm',
56-
cache_dir=PDF_CACHE,
5756
)
5857
print(f'{i_:03}: {len(pdf)}')
5958
file = OUT_DIR / f'output_{i_:03}.pdf'

pydf/wkhtmltopdf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import re
33
import subprocess
4+
import tempfile
45

56
from pathlib import Path
67

@@ -63,6 +64,10 @@ class AsyncPydf:
6364
def __init__(self, *, max_processes=20, loop=None):
6465
self.semaphore = asyncio.Semaphore(value=max_processes, loop=loop)
6566
self.loop = loop
67+
cache_dir = Path(tempfile.gettempdir()) / 'pydf_cache'
68+
if not cache_dir.exists():
69+
Path.mkdir(cache_dir)
70+
self.cache_dir = str(cache_dir)
6671

6772
async def generate_pdf(self,
6873
html,
@@ -72,6 +77,7 @@ async def generate_pdf(self,
7277
creator=None,
7378
producer=None,
7479
**cmd_args):
80+
cmd_args.setdefault('cache_dir', self.cache_dir)
7581
cmd_args = [WK_PATH] + _convert_args(cmd_args)
7682
async with self.semaphore:
7783
p = await asyncio.create_subprocess_exec(

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def run(self):
3838
'License :: OSI Approved :: MIT License',
3939
'Programming Language :: Python',
4040
'Programming Language :: Python :: 3',
41-
'Programming Language :: Python :: 3.5',
4241
'Programming Language :: Python :: 3.6',
4342
'Topic :: Internet :: WWW/HTTP',
4443
],

0 commit comments

Comments
 (0)