[web2py] Re: Processing taking a long time in web2py?
I'm asking why opening a process in a python script takes much less time than opening the same python code/process in a web2py application. Also yes I will consider your second point but I think I will hide it behind authentication On Thursday, 17 November 2016 22:53:50 UTC, Niphlod wrote: > > well... you're asking why opening a process in python rather than doing it > directly takes more time. no wonders there: of course it takes more time! > Especially if your process writes lots to stdout/stderr that python needs > to collect. > > BTW: never ever ever run ANY external process from the webserver: you > could easily be DDoSed AND you incur in lots of issues (random timeouts, > memory issues, leaks, and aforementioned slowness). > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Processing taking a long time in web2py?
def run(): import os import subprocess ex = os.path.join('/home/user', "executable") for i in range(2500): a = -5. b = 50.0 proc = subprocess.Popen([ex, str(a), str(b),],stdout=subprocess.PIPE ) (out, err) = proc.communicate() redirect(URL('here', args=request.args(0))) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Processing taking a long time in web2py?
Hi I have a function that runs an executable using subprocess. I want to run it in a loop, say 2500 times. When I run this loop in a python script it takes 5 seconds. When I run this loop on a web2py page it takes 23 seconds. When I run this loop in web2py with reading and writing to an sqlite database it takes 30seconds. Do you guys have any ideas on how to reduce this run time? Thanks! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Copy and insert a row in a database
On Tuesday, 8 November 2016 17:54:48 UTC, Anthony wrote: > > > The second argument to .store() should be the original filename (which > will then be encoded again), not a full file path. To get the original > filename, use the .retrieve() method instead of manually constructing the > file path and opening the file: > > filename, stream = db.name.file.retrieve(a.file) > db.name.insert(..., file=db.name.file.store(stream, filename)) > > Also, your use of a.file implies the upload field is named "file", but in > your insert code, you use "file_up" -- not sure which is correct. > > Anthony > Thanks this is exactly what I was after! (I had edited the original code down to something more readable so it should have been consistent as "file") -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Copy and insert a row in a database
Hi guys, I'm making a function to copy and insert a row of a database. I want to copy and rename a file but the automatic b16 renaming becomes too long and breaks when you make a copy of a copy. It also breaks some of my later processing of the file. Here is some code: def copy(): import os a = db.name(db.name.id== request.args(0)) filepath = os.path.join(request.folder, 'uploads', a.file) stream = open(filepath, 'rb') db.name.insert(title= '%s_copy' % (a.title), file_up = db.name.file.store(stream, filepath), -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: data processing conditional on form input
Solution was: def processing(): if db.dbname(db.dbname.id == request.args(0)).file == 'file1': pathDir = /path/to/file1 else: pathDir = /path/to/file2 -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] data processing conditional on form input
Hey guys I have a relatively simple question to ask: I have a form storing my input in an sqlite database. Based on the response in the form I want to choose a certain file stored on the server. How do I go about writing the if statement? eg db = DAL('sqlite://storage.sqlite') db.define_table('dbname', Field('file', requires=IS_IN_SET(['file1','file2'] ))) Then I want to write something conditional on the input being eg file1 def processing(): if db.dbname(request.args(0)).file == file1: pathDir = /path/to/file1 else: pathDir = /path/to/file2 What should I use to tell the processing to use the current row in the database? How do I tell the server to start processing once the form has been submitted? Thanks! -a noob -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.