Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pipeline
Commits
bc083f24
Commit
bc083f24
authored
Feb 27, 2013
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #191 from cyberdelia/thread-it
what if we use thread ?
parents
0f01826b
ac73ec2d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
pipeline/compilers/__init__.py
+16
-10
No files found.
pipeline/compilers/__init__.py
View file @
bc083f24
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
multiprocessing
import
os
import
os
import
subprocess
import
subprocess
from
multiprocessing.pool
import
ThreadPool
from
django.contrib.staticfiles
import
finders
from
django.contrib.staticfiles
import
finders
from
django.core.files.base
import
ContentFile
from
django.core.files.base
import
ContentFile
from
django.utils.encoding
import
smart_str
,
smart_bytes
from
django.utils.encoding
import
smart_str
,
smart_bytes
...
@@ -17,31 +20,34 @@ class Compiler(object):
...
@@ -17,31 +20,34 @@ class Compiler(object):
def
__init__
(
self
,
storage
=
default_storage
,
verbose
=
False
):
def
__init__
(
self
,
storage
=
default_storage
,
verbose
=
False
):
self
.
storage
=
storage
self
.
storage
=
storage
self
.
verbose
=
verbose
self
.
verbose
=
verbose
self
.
pool
=
ThreadPool
(
processes
=
multiprocessing
.
cpu_count
())
@property
@property
def
compilers
(
self
):
def
compilers
(
self
):
return
[
to_class
(
compiler
)
for
compiler
in
settings
.
PIPELINE_COMPILERS
]
return
[
to_class
(
compiler
)
for
compiler
in
settings
.
PIPELINE_COMPILERS
]
def
compile
(
self
,
paths
,
force
=
False
):
def
compile
(
self
,
paths
,
force
=
False
):
for
index
,
input_path
in
enumerate
(
paths
):
def
_compile
(
input_path
):
for
compiler
in
self
.
compilers
:
for
compiler
in
self
.
compilers
:
compiler
=
compiler
(
verbose
=
self
.
verbose
,
storage
=
self
.
storage
)
compiler
=
compiler
(
verbose
=
self
.
verbose
,
storage
=
self
.
storage
)
if
compiler
.
match_file
(
input_path
):
if
compiler
.
match_file
(
input_path
):
output_path
=
self
.
output_path
(
input_path
,
compiler
.
output_extension
)
output_path
=
self
.
output_path
(
input_path
,
compiler
.
output_extension
)
paths
[
index
]
=
output_path
infile
=
finders
.
find
(
input_path
)
outfile
=
finders
.
find
(
output_path
)
if
outfile
is
None
:
outfile
=
self
.
output_path
(
infile
,
compiler
.
output_extension
)
outdated
=
True
else
:
outdated
=
self
.
is_outdated
(
input_path
,
output_path
)
try
:
try
:
infile
=
finders
.
find
(
input_path
)
outfile
=
finders
.
find
(
output_path
)
if
outfile
is
None
:
outfile
=
self
.
output_path
(
infile
,
compiler
.
output_extension
)
outdated
=
True
else
:
outdated
=
self
.
is_outdated
(
input_path
,
output_path
)
compiler
.
compile_file
(
infile
,
outfile
,
outdated
=
outdated
,
force
=
force
)
compiler
.
compile_file
(
infile
,
outfile
,
outdated
=
outdated
,
force
=
force
)
except
CompilerError
:
except
CompilerError
:
if
not
self
.
storage
.
exists
(
output_path
)
or
settings
.
DEBUG
:
if
not
self
.
storage
.
exists
(
output_path
)
or
settings
.
DEBUG
:
raise
raise
return
paths
return
output_path
else
:
return
input_path
return
self
.
pool
.
map
(
_compile
,
paths
)
def
output_path
(
self
,
path
,
extension
):
def
output_path
(
self
,
path
,
extension
):
path
=
os
.
path
.
splitext
(
path
)
path
=
os
.
path
.
splitext
(
path
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment