[issue13670] Increase test coverage for pstats.py

2019-03-16 Thread andrea crotti
andrea crotti added the comment: It has been a long time but if it's still useful sure. I can see some tests have been added in commit 863b1e4d0e95036bca4e97c1b8b2ca72c19790fb but if these are still relevant I'm happy to go ahead. -- ___ Python

Re: [OT] Usage of U+00B6 PILCROW SIGN (was: generator slides review and Python doc (+/- text bug))

2014-02-04 Thread andrea crotti
2014-02-04 wxjmfa...@gmail.com: Le mardi 4 février 2014 15:39:54 UTC+1, Jerry Hill a écrit : Useless and really ugly. I think this whole discussion is rather useless instead, why do you care since you're not going to use this tool anyway? --

Re: generator slides review and Python doc (+/- text bug)

2014-02-03 Thread andrea crotti
2014-02-03 wxjmfa...@gmail.com: generator slides review and Python doc I do not know what tool is used to produce such slides. When the mouse is over a a text like a title (H* ... \H* ???) the text get transformed and a colored eol is appearing. Example with the slide #3: Even numbers

Re: generator slides review

2014-02-03 Thread andrea crotti
2014-02-03 Terry Reedy tjre...@udel.edu: On 2/2/2014 5:40 AM, andrea crotti wrote: In general, use assert (== AssertionError) to check program logic (should never raise). Remember that assert can be optimized away. Use other exceptions to check user behavior. So I believe that ValueError

Re: generator slides review

2014-02-02 Thread andrea crotti
2014-02-02 Terry Reedy tjre...@udel.edu: On 2/1/2014 9:12 AM, andrea crotti wrote: Comments: The use is assert in the first slide seem bad in a couple of different respects. Why is it bad? It's probably not necessary but since we ask for a range it might be good to check if the range

Re: generator slides review

2014-02-02 Thread andrea crotti
2014-02-01 Miki Tebeka miki.teb...@gmail.com: My 2 cents: slide 4: [i*2 for i in range(10)] Well this is not correct in theory because the end should be the max number, not the number of elements. So it should be [i*2 for i in range(10/2)] which might be fine but it's not really more clear

Re: generator slides review

2014-02-02 Thread andrea crotti
The slides are updated now 2014-02-02 andrea crotti andrea.crott...@gmail.com: 2014-02-01 Miki Tebeka miki.teb...@gmail.com: My 2 cents: slide 4: [i*2 for i in range(10)] Well this is not correct in theory because the end should be the max number, not the number of elements. So

Re: generator slides review

2014-02-02 Thread andrea crotti
in which explain things, to tell a clear story in a way 2014-02-02 andrea crotti andrea.crott...@gmail.com: The slides are updated now 2014-02-02 andrea crotti andrea.crott...@gmail.com: 2014-02-01 Miki Tebeka miki.teb...@gmail.com: My 2 cents: slide 4: [i*2 for i in range(10)] Well

Re: generator slides review

2014-02-02 Thread andrea crotti
Thanks everyone for your feedback. The talk I think went well, maybe I was too fast because I only used 21 minutes. From the audience feedback, there were some questions about my Buggy code example, so yes probably it's not a good example since it's too artificial. I'll have to find something

generator slides review

2014-02-01 Thread andrea crotti
I'm giving a talk tomorrow @Fosdem about generators/iterators/iterables.. The slides are here (forgive the strange Chinese characters): https://dl.dropboxusercontent.com/u/3183120/talks/generators/index.html#3 and the code I'm using is:

Re: how to avoid spaghetti in Python?

2014-01-21 Thread andrea crotti
2014/1/21 CM cmpyt...@gmail.com: I've been learning and using Python for a number of years now but never really go particularly disciplined about all good coding practices. I've definitely learned *some*, but I'm hoping this year to take a good step up in terms of refactoring,

Re: lxml tostring quoting too much

2013-08-07 Thread andrea crotti
2013/8/6 Chris Down ch...@chrisdown.name: On 2013-08-06 18:38, andrea crotti wrote: I would really like to do the following: from lxml import etree as ET from lxml.builder import E url = http://something?x=10y=20; l = E.link(url) ET.tostring(l) - linkhttp://something?x=10y=20/link

lxml tostring quoting too much

2013-08-06 Thread andrea crotti
I would really like to do the following: from lxml import etree as ET from lxml.builder import E url = http://something?x=10y=20; l = E.link(url) ET.tostring(l) - linkhttp://something?x=10y=20/link However the lxml tostring always quotes the , I can't find a way to tell it to avoid quoting it.

decorator to fetch arguments from global objects

2013-06-18 Thread andrea crotti
Using a CouchDB server we have a different database object potentially for every request. We already set that db in the request object to make it easy to pass it around form our django app, however it would be nice if I could set it once in the API and automatically fetch it from there.

Re: python-django for dynamic web survey?

2013-06-18 Thread andrea crotti
Django makes your life a lot easier in many ways, but you still need some time to learn it. The task you're trying it's not trivial though, depending on your experience it might take a while with any library/framework.. -- http://mail.python.org/mailman/listinfo/python-list

Re: decorator to fetch arguments from global objects

2013-06-18 Thread andrea crotti
2013/6/18 Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de andrea crotti andrea.crotti.0 at gmail.com writes: Using a CouchDB server we have a different database object potentially for every request. We already set that db in the request object to make it easy to pass

Re: decorator to fetch arguments from global objects

2013-06-18 Thread andrea crotti
2013/6/18 Terry Reedy tjre...@udel.edu On 6/18/2013 5:47 AM, andrea crotti wrote: Using a CouchDB server we have a different database object potentially for every request. We already set that db in the request object to make it easy to pass it around form our django app, however it would

Re: Getting a callable for any value?

2013-05-29 Thread andrea crotti
On 05/29/2013 06:46 PM, Croepha wrote: Is there anything like this in the standard library? class AnyFactory(object): def __init__(self, anything): self.product = anything def __call__(self): return self.product def __repr__(self): return %s.%s(%r) % (self.__class__.__module__,

pip and different branches?

2013-05-20 Thread andrea crotti
We use github and we work on many different branches at the same time. The problem is that we have 5 repos now, and for each repo we might have the same branches on all of them. Now we use pip and install requirements such as: git+ssh://g...@github.com/repo.git@dev Now the problem is that the

Re: dynamic forms generation

2013-04-19 Thread andrea crotti
Well I think since we are using django anyway (and bottle on the API side) I'm not sure why we would use flask forms for this.. Anyway the main question is probably, is it worth to try to define a DSL or not? The problem I see is that we have a lot and very complex requirements, trying to define

dynamic forms generation

2013-04-16 Thread andrea crotti
We are re-designing a part of our codebase, which should in short be able to generate forms with custom fields. We use django for the frontend and bottle for the backend (using CouchDB as database), and at the moment we simply plug extra fields on normal django forms. This is not really

Mixin way?

2013-04-03 Thread andrea crotti
I have some classes that have shared behaviours, for example in our scenario an object can be visited, where something that is visitable would have some behaviour like --8---cut here---start-8--- class Visitable(Mixin): FIELDS = { 'visits': [],

Re: Mixin way?

2013-04-03 Thread andrea crotti
2013/4/3 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info [snip] So, if you think of Visitable as a gadget that can be strapped onto your MyObj as a component, then composition is probably a better design. But if you think of Visitable as a mere collection of behaviour and state, then a

Re: groupby behaviour

2013-02-26 Thread andrea crotti
2013/2/26 Ian Kelly ian.g.ke...@gmail.com: On Tue, Feb 26, 2013 at 9:27 AM, andrea crotti andrea.crott...@gmail.com wrote: So I was trying to use groupby (which I used in the past), but I noticed a very strange thing if using list on the result: As stated in the docs: The returned group

Re: running multiple django/bottle instances

2013-01-07 Thread andrea crotti
a production server like Apache, your problem is actually not Python related. If you want to run your applications on different ports, take a look on e.g. Apaches virtual host configurations. http://httpd.apache.org/docs/2.2/vhosts/examples.html Am 03.01.2013 17:35, schrieb Andrea Crotti: I'm working

running multiple django/bottle instances

2013-01-03 Thread Andrea Crotti
I'm working on a quite complex web app that uses django and bottle (bottle for the API which is also restful). Before I came they started to use a staging server to be able to try out things properly before they get published, but now we would like to have the possibility to see multiple

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
Yes I wanted to avoid to do something too complex, anyway I'll just comment it well and add a link to the original code.. But this is now failing to me: def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): # Perform first fork. try: pid = os.fork() if

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
Ah sure that makes sense! But actually why do I need to move away from the current directory of the parent process? In my case it's actually useful to be in the same directory, so maybe I can skip that part, or otherwise I need another chdir after.. --

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
2012/12/11 peter pjmak...@gmail.com: On 12/11/2012 10:25 AM, andrea crotti wrote: Ah sure that makes sense! But actually why do I need to move away from the current directory of the parent process? In my case it's actually useful to be in the same directory, so maybe I can skip that part

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
2012/12/11 Jean-Michel Pichavant jeanmic...@sequans.com: - Original Message - So I implemented a simple decorator to run a function in a forked process, as below. It works well but the problem is that the childs end up as zombies on one machine, while strangely I can't reproduce the

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
2012/12/11 Dennis Lee Bieber wlfr...@ix.netcom.com: On Tue, 11 Dec 2012 10:34:23 -0300, peter pjmak...@gmail.com declaimed the following in gmane.comp.python.general: stderrfile = '%s/error.log' % os.getcwd() stdoutfile = '%s/out.log' % os.getcwd() Ouch... stdoutfile =

Re: creating size-limited tar files

2012-11-14 Thread andrea crotti
2012/11/14 Kushal Kumaran kushal.kumaran+pyt...@gmail.com: Well, well, I was wrong, clearly. I wonder if this is fixable. -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list But would it not be possible to use the pipe in memory in theory? That would be way faster

Re: creating size-limited tar files

2012-11-14 Thread andrea crotti
2012/11/14 Dave Angel d...@davea.name: On 11/14/2012 10:56 AM, andrea crotti wrote: Ok this is all very nice, but: [andrea@andreacrotti tar_baller]$ time python2 test_pipe.py /dev/null real 0m21.215s user 0m0.750s sys 0m1.703s [andrea@andreacrotti tar_baller]$ time ls -lR /home

Re: creating size-limited tar files

2012-11-14 Thread Andrea Crotti
On 11/14/2012 04:33 PM, Dave Angel wrote: Well, as I said, I don't see how the particular timing has anything to do with the rest of the thread. If you want to do an ls within a Python program, go ahead. But if all you need can be done with ls itself, then it'll be slower to launch python just

Re: creating size-limited tar files

2012-11-08 Thread andrea crotti
2012/11/7 Oscar Benjamin oscar.j.benja...@gmail.com: Correct. But if you read the rest of Alexander's post you'll find a suggestion that would work in this case and that can guarantee to give files of the desired size. You just need to define your own class that implements a write() method

Re: creating size-limited tar files

2012-11-08 Thread andrea crotti
2012/11/8 andrea crotti andrea.crott...@gmail.com: Yes yes I saw the answer, but now I was thinking that what I need is simply this: tar czpvf - /path/to/archive | split -d -b 100M - tardisk since it should run only on Linux it's probably way easier, my script will then only need

Re: creating size-limited tar files

2012-11-07 Thread Andrea Crotti
On 11/07/2012 08:32 PM, Roy Smith wrote: In article 509ab0fa$0$6636$9b4e6...@newsspool2.arcor-online.net, Alexander Blinne n...@blinne.net wrote: I don't know the best way to find the current size, I only have a general remark. This solution is not so good if you have to impose a hard limit

Re: accepting file path or file object?

2012-11-05 Thread andrea crotti
2012/11/5 Peter Otten __pete...@web.de: I sometimes do something like this: $ cat xopen.py import re import sys from contextlib import contextmanager @contextmanager def xopen(file=None, mode=r): if hasattr(file, read): yield file elif file == -: if w in mode:

lazy properties?

2012-11-01 Thread Andrea Crotti
Seeing the wonderful lazy val in Scala I thought that I should try to get the following also in Python. The problem is that I often have this pattern in my code: class Sample: def __init__(self): self._var = None @property def var(self): if self._var is None:

Re: Nice solution wanted: Hide internal interfaces

2012-10-30 Thread andrea crotti
2012/10/30 alex23 wuwe...@gmail.com: On Oct 30, 2:33 am, Johannes Bauer dfnsonfsdu...@gmx.de wrote: I'm currently looking for a good solution to the following problem: I have two classes A and B, which interact with each other and which interact with the user. Instances of B are always created

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Jean-Michel Pichavant jeanmic...@sequans.com: return NumWrapper(self.number + 1) still returns a(nother) mutable object. So what's the point of all this ? JM Well sure but it doesn't modify the first object, just creates a new one. There are in general good reasons to do

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 andrea crotti andrea.crott...@gmail.com: Well sure but it doesn't modify the first object, just creates a new one. There are in general good reasons to do that, for example I can then compose things nicely: num.increment().increment() or I can parallelize operations safely

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Jean-Michel Pichavant jeanmic...@sequans.com: In an OOP language num.increment() is expected to modify the object in place. So I think you're right when you say that functional languages technics do not necessarily apply to Python, because they don't. I would add that what

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Chris Angelico ros...@gmail.com: On Tue, Oct 30, 2012 at 2:55 AM, Paul Rubin no.email@nospam.invalid wrote: andrea crotti andrea.crott...@gmail.com writes: and we want to change its state incrementing the number ... the immutability purists would instead suggest to do

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread andrea crotti
2012/10/29 Johannes Bauer dfnsonfsdu...@gmx.de: Hi there, I'm currently looking for a good solution to the following problem: I have two classes A and B, which interact with each other and which interact with the user. Instances of B are always created by A. Now I want A to call some

Re: resume execution after catching with an excepthook?

2012-10-25 Thread andrea crotti
2012/10/25 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: On Wed, 24 Oct 2012 13:51:30 +0100, andrea crotti wrote: So I would like to be able to ask for confirmation when I receive a C-c, and continue if the answer is N/n. I don't think there is any way to do this directly. Without

resume execution after catching with an excepthook?

2012-10-24 Thread andrea crotti
So I would like to be able to ask for confirmation when I receive a C-c, and continue if the answer is N/n. I'm already using an exception handler set with sys.excepthook, but I can't make it work with the confirm_exit, because it's going to quit in any case.. A possible solution would be to do

Re: Testing against multiple versions of Python

2012-10-19 Thread andrea crotti
2012/10/19 Michele Simionato michele.simion...@gmail.com: Yesterday I released a new version of the decorator module. It should run under Python 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3. I did not have the will to install on my machine 8 different versions of Python, so I just tested it with

Re: locking files on Linux

2012-10-19 Thread andrea crotti
2012/10/18 Oscar Benjamin oscar.j.benja...@gmail.com: The lock is cooperative. It does not prevent the file from being opened or overwritten. It only prevents any other process from obtaining the lock. Here you open the file with mode 'w' which truncates the file instantly (without checking

Re: locking files on Linux

2012-10-18 Thread andrea crotti
2012/10/18 Grant Edwards invalid@invalid.invalid: On 2012-10-18, andrea crotti andrea.crott...@gmail.com wrote: File locks under Unix have historically been advisory. That means that programs have to _choose_ to pay attention to them. Most programs do not. Linux does support mandatory

Re: locking files on Linux

2012-10-18 Thread andrea crotti
2012/10/18 Oscar Benjamin oscar.j.benja...@gmail.com: Why not come up with a test that actually shows you if it works? Here are two suggestions: 1) Use time.sleep() so that you know how long the lock is held for. 2) Write different data into the file from each process and see what you end

Re: Generating C++ code

2012-10-10 Thread andrea crotti
2012/10/10 Jean-Michel Pichavant jeanmic...@sequans.com: Well, the C++ code will end up running on a MIPS on a SOC, unfortunately, python is not an option here. The xml to C++ makes a lot of sense, because only a small part of the code is generated that way (everything related to log fatal

Re: Generating C++ code

2012-10-09 Thread Andrea Crotti
On 10/09/2012 05:00 PM, Jean-Michel Pichavant wrote: Greetings, I'm trying to generate C++ code from an XML file. I'd like to use a template engine, which imo produce something readable and maintainable. My google search about this subject has been quite unsuccessful, I've been redirected to

Re: PHP vs. Python

2012-09-25 Thread andrea crotti
2012/9/25 tejas.tank@gmail.com: On Thursday, 23 December 2004 03:33:36 UTC+5:30, (unknown) wrote: Anyone know which is faster? I'm a PHP programmer but considering getting into Python ... did searches on Google but didn't turn much up on this. Thanks! Stephen Here some helpful

Re: Python presentations

2012-09-24 Thread andrea crotti
For anyone interested, I already moved the slides on github (https://github.com/AndreaCrotti/pyconuk2012_slides) and for example the decorator slides will be generated from this: https://raw.github.com/AndreaCrotti/pyconuk2012_slides/master/deco_context/deco.rst Notice the literalinclude with

Re: 'str' object does not support item assignment

2012-09-23 Thread Andrea Crotti
On 09/23/2012 07:31 PM, jimbo1qaz wrote: spots[y][x]=mark fails with a 'str' object does not support item assignment error,even though: a=[[a]] a[0][0]=b and: a=[[a]] a[0][0]=100 both work. Spots is a nested list created as a copy of another list. But a = a a[0] = 'c' fails for the

Re: subprocess call is not waiting.

2012-09-19 Thread andrea crotti
2012/9/18 Dennis Lee Bieber wlfr...@ix.netcom.com: Unless you have a really massive result set from that ls, that command probably ran so fast that it is blocked waiting for someone to read the PIPE. I tried also with ls -lR / and that definitively takes a while to run, when I do

Re: subprocess call is not waiting.

2012-09-19 Thread andrea crotti
2012/9/19 Hans Mulder han...@xs4all.nl: Yes: using top is an observation problem. Top, as the name suggests, shows only the most active processes. Sure but ls -lR / is a very active process if you try to run it.. Anyway as written below I don't need this anymore. It's quite possible that

Re: Python presentations

2012-09-19 Thread andrea crotti
2012/9/19 Trent Nelson tr...@snakebite.org: FWIW, I gave a presentation on decorators to the New York Python User Group back in 2008. Relevant blog post: http://blogs.onresolve.com/?p=48 There's a link to the PowerPoint presentation I used in the first paragraph.

Re: subprocess call is not waiting.

2012-09-18 Thread andrea crotti
I have a similar problem, something which I've never quite understood about subprocess... Suppose I do this: proc = subprocess.Popen(['ls', '-lR'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) now I created a process, which has a PID, but it's not running apparently... It only seems to run

Re: Decorators not worth the effort

2012-09-14 Thread andrea crotti
I think one very nice and simple example of how decorators can be used is this: def memoize(f, cache={}, *args, **kwargs): def _memoize(*args, **kwargs): key = (args, str(kwargs)) if not key in cache: cache[key] = f(*args, **kwargs) return cache[key]

Re: Decorators not worth the effort

2012-09-14 Thread andrea crotti
2012/9/14 Chris Angelico ros...@gmail.com: Trouble is, you're starting with a pretty poor algorithm. It's easy to improve on what's poor. Memoization can still help, but I would start with a better algorithm, such as: def fib(n): if n=1: return 1 a,b=1,1 for i in

main and dependent objects

2012-09-13 Thread andrea crotti
I am in a situation where I have a class Obj which contains many attributes, and also contains logically another object of class Dependent. This dependent_object, however, also needs to access many fields of the original class, so at the moment we did something like this: class Dependent:

Re: main and dependent objects

2012-09-13 Thread andrea crotti
2012/9/13 Jean-Michel Pichavant jeanmic...@sequans.com: Nothing shocking right here imo. It looks like a classic parent-child implementation. However it seems the relation between Obj and Dependent are 1-to-1. Since Dependent need to access all Obj attributes, are you sure that Dependent

Re: Python presentations

2012-09-13 Thread andrea crotti
2012/9/13 William R. Wing (Bill Wing) w...@mac.com: [byte] Speaking from experience as both a presenter and an audience member, please be sure that anything you demo interactively you include in your slide deck (even if only as an addendum). I assume your audience will have access to

Re: Python presentations

2012-09-13 Thread Andrea Crotti
On 09/13/2012 11:58 PM, Miki Tebeka wrote: What do you think work best in general? I find typing during class (other than small REPL examples) time consuming and error prone. What works well for me is to create a slidy HTML presentation with asciidoc, then I can include code snippets that

Re: pyQT performance?

2012-09-10 Thread Andrea Crotti
On 09/10/2012 07:29 PM, jayden.s...@gmail.com wrote Have you ever used py2exe? After converting the python codes to executable, does it save the time of interpreting the script language? Thank a lot! Py2exe normally never speeds up anything, simply because it doesn't convert to executable,

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread andrea crotti
2012/8/20 kj no.em...@please.post: In roy-ca6d77.17031119082...@news.panix.com Roy Smith r...@panix.com writes This means that no library code can ever count on, for example, being able to reliably find the path to the file that contains the definition of __main__. That's a weakness, IMO.

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread andrea crotti
2012/8/20 Roy Smith r...@panix.com: In article k0tf8g$adc$1...@news.albasani.net, Walter Hurry walterhu...@lavabit.com wrote: It is difficult to think of a sensible use for os.chdir, IMHO. It is true that you can mostly avoid chdir() by building absolute pathnames, but it's often more

Re: Sharing code between different projects?

2012-08-16 Thread andrea crotti
2012/8/16 Jean-Michel Pichavant jeanmic...@sequans.com: SVN allows to define external dependencies, where one repository will actually checkout another one at a specific version. If SVN does it, I guess any decent SCM also provide such feature. Assuming our project is named 'common', and you

Re: how to call perl script from html using python

2012-08-16 Thread andrea crotti
2012/8/16 Pervez Mulla mullaper...@gmail.com: Hey Steven , Thank you for your response, I will in detail now about my project, Actually the project entire backend in PERL language , Am using Django framework for my front end . I have written code for signup page in python , which is

Re: Sharing code between different projects?

2012-08-16 Thread andrea crotti
2012/8/16 andrea crotti andrea.crott...@gmail.com: Unfortunately I think you guess wrong http://forums.perforce.com/index.php?/topic/553-perforce-svnexternals-equivalent/ Anyway with views and similar things is not that hard to implement the same thing.. I'm very happy to say that I

Re: Sharing code between different projects?

2012-08-15 Thread andrea crotti
2012/8/14 Cameron Simpson c...@zip.com.au: Having just skimmed this thread, one thing I haven't quite seen suggested is this: Really do make a third utilities project, and treat the project and deploy as separate notions. So to actually run/deploy project A's code you'd have a short script

Re: Sharing code between different projects?

2012-08-15 Thread andrea crotti
Also looking at logilab-common I thought that it would be great if we could actually make this common library even open source, and use it as one of the other many external libraries. Since Python code is definitively not the the core business of this company I might even convince them, but the

Re: Sharing code between different projects?

2012-08-14 Thread andrea crotti
2012/8/13 Rob Day robert@merton.oxon.org: I'd just create a module - called shared_utils.py or similar - and import that in both projects. It might be a bit messy if there's no 'unifying theme' to the module - but surely it'd be a lot less messy than your TempDirectory class, and anyone

Re: Sharing code between different projects?

2012-08-14 Thread andrea crotti
2012/8/14 Jean-Michel Pichavant jeanmic...@sequans.com: I can think of logilab-common (http://www.logilab.org/848/) Having a company-wide python module properly distributed is one to achieve your goal. Without distributing your module to the public, there's a way to have a pypi-like server

Sharing code between different projects?

2012-08-13 Thread andrea crotti
I am in the situation where I am working on different projects that might potentially share a lot of code. I started to work on project A, then switched completely to project B and in the transiction I copied over a lot of code with the corresponding tests, and I started to modify it. Now it's

Re: CRC-checksum failed in gzip

2012-08-02 Thread andrea crotti
2012/8/1 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: When you start using threads, you have to expect these sorts of intermittent bugs unless you are very careful. My guess is that you have a bug where two threads read from the same file at the same time. Since each read shares

Re: CRC-checksum failed in gzip

2012-08-02 Thread andrea crotti
2012/8/2 Laszlo Nagy gand...@shopzeus.com: Your example did not share the file object between threads. Here an example that does that: class OpenAndRead(threading.Thread): def run(self): global fz fz.read(100) if __name__ == '__main__': fz =

Re: CRC-checksum failed in gzip

2012-08-02 Thread andrea crotti
2012/8/2 andrea crotti andrea.crott...@gmail.com: Ok sure that makes sense, but then this explanation is maybe not right anymore, because I'm quite sure that the file object is *not* shared between threads, everything happens inside a thread.. I managed to get some errors doing

Re: Pass data to a subprocess

2012-08-01 Thread andrea crotti
2012/8/1 Laszlo Nagy gand...@shopzeus.com: I was just surprised that it worked better than I expected even without Pipes and Queues, but now I understand why.. Anyway now I would like to be able to detach subprocesses to avoid the nasty code reloading that I was talking about in another

Re: Pass data to a subprocess

2012-08-01 Thread andrea crotti
2012/8/1 Laszlo Nagy gand...@shopzeus.com: On thing is sure: os.fork() doesn't work under Microsoft Windows. Under Unix, I'm not sure if os.fork() can be mixed with multiprocessing.Process.start(). I could not find official documentation on that. This must be tested on your actual platform.

CRC-checksum failed in gzip

2012-08-01 Thread andrea crotti
We're having some really obscure problems with gzip. There is a program running with python2.7 on a 2.6.18-128.el5xen (red hat I think) kernel. Now this program does the following: if filename == 'out2.txt': out2 = open('out2.txt') elif filename == 'out2.txt.gz' out2 =

Re: CRC-checksum failed in gzip

2012-08-01 Thread andrea crotti
2012/8/1 Laszlo Nagy gand...@shopzeus.com: On 2012-08-01 12:39, andrea crotti wrote: We're having some really obscure problems with gzip. There is a program running with python2.7 on a 2.6.18-128.el5xen (red hat I think) kernel. Now this program does the following: if filename == 'out2.txt

Re: CRC-checksum failed in gzip

2012-08-01 Thread andrea crotti
Full traceback: Exception in thread Thread-8: Traceback (most recent call last): File /user/sim/python/lib/python2.7/threading.py, line 530, in __bootstrap_inner self.run() File /user/sim/tests/llif/AutoTester/src/AutoTester2.py, line 67, in run self.processJobData(jobData, logger)

Re: Pass data to a subprocess

2012-08-01 Thread andrea crotti
2012/8/1 Roy Smith r...@panix.com: In article mailman.2809.1343809166.4697.python-l...@python.org, Laszlo Nagy gand...@shopzeus.com wrote: Yes, I think that is correct. Instead of detaching a child process, you can create independent processes and use other frameworks for IPC. For example,

Re: CRC-checksum failed in gzip

2012-08-01 Thread andrea crotti
2012/8/1 Laszlo Nagy gand...@shopzeus.com: there seems to be no clear pattern and just randmoly fails. The file is also just open for read from this program, so in theory no way that it can be corrupted. Yes, there is. Gzip stores CRC for compressed *blocks*. So if the file is not

Re: Pass data to a subprocess

2012-08-01 Thread andrea crotti
2012/8/1 Laszlo Nagy gand...@shopzeus.com: So detaching the child process will not make IPC stop working. But exiting from the original parent process will. (And why else would you detach the child?) -- http://mail.python.org/mailman/listinfo/python-list Well it makes perfect sense if it

Re: CRC-checksum failed in gzip

2012-08-01 Thread andrea crotti
2012/8/1 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: On Wed, 01 Aug 2012 14:01:45 +0100, andrea crotti wrote: Full traceback: Exception in thread Thread-8: DANGER DANGER DANGER WILL ROBINSON!!! Why didn't you say that there were threads involved? That puts a completely

Re: CRC-checksum failed in gzip

2012-08-01 Thread andrea crotti
2012/8/1 Laszlo Nagy gand...@shopzeus.com: Thanks a lot, that makes a lot of sense.. I haven't given this detail before because I didn't write this code, and I forgot that there were threads involved completely, I'm just trying to help to fix this bug. Your explanation makes a lot of sense,

Re: Pass data to a subprocess

2012-07-31 Thread andrea crotti
def procs(): mp = MyProcess() # with the join we are actually waiting for the end of the running time mp.add([1,2,3]) mp.start() mp.add([2,3,4]) mp.join() print(mp) I think I got it now, if I already just mix the start before another add, inside the

Re: Pass data to a subprocess

2012-07-31 Thread andrea crotti
2012/7/31 Laszlo Nagy gand...@shopzeus.com: I think I got it now, if I already just mix the start before another add, inside the Process.run it won't see the new data that has been added after the start. So this way is perfectly safe only until the process is launched, if it's running I need

Re: py2c - an open source Python to C/C++ is looking for developers

2012-07-30 Thread andrea crotti
2012/7/30 maniandra...@gmail.com: I created py2c ( http://code.google.com/p/py2c )- an open source Python to C/C++ translator! py2c is looking for developers! To join create a posting in the py2c-discuss Google Group or email me! Thanks PS:I hope this is the appropiate group for this

regexps to objects

2012-07-27 Thread andrea crotti
I have some complex input to parse (with regexps), and I would like to create nice objects directy from them. The re module doesn't of course try to conver to any type, so I was playing around to see if it's worth do something as below, where I assign a constructor to every regexp and build an

Re: reloading code and multiprocessing

2012-07-27 Thread andrea crotti
2012/7/25 andrea crotti andrea.crott...@gmail.com: I would also like to avoid this in general, but we have many subprocesses to launch and some of them might take weeks, so we need to have a process which is always running, because there is never a point in time where we can just say let's

Re: reloading code and multiprocessing

2012-07-25 Thread andrea crotti
2012/7/23 Chris Angelico ros...@gmail.com: That would probably be correct. However, I still think you may be fighting against the language instead of playing to its strengths. I've never fiddled with sys.modules like that, but I know some have, without problem. ChrisA --

Dumping all the sql statements as backup

2012-07-25 Thread andrea crotti
I have some long running processes that do very long simulations which at the end need to write things on a database. At the moment sometimes there are network problems and we end up with half the data on the database. The half-data problem is probably solved easily with sessions and sqlalchemy

Re: Dumping all the sql statements as backup

2012-07-25 Thread andrea crotti
2012/7/25 Jack tdl...@gmail.com Since you know the content of what the sql code is, why not just build the sql file(s) needed and store them so that in case of a burp you can just execute the code file. If you don't know the exact sql code, dump it to a file as the statements are

Re: reloading code and multiprocessing

2012-07-23 Thread andrea crotti
2012/7/20 Chris Angelico ros...@gmail.com: On Thu, Jul 19, 2012 at 8:15 PM, andrea crotti andrea.crott...@gmail.com wrote: We need to be able to reload code on a live system. This live system has a daemon process always running but it runs many subprocesses with multiprocessing

reloading code and multiprocessing

2012-07-19 Thread andrea crotti
We need to be able to reload code on a live system. This live system has a daemon process always running but it runs many subprocesses with multiprocessing, and the subprocesses might have a short life... Now I found a way to reload the code successfully, as you can see from this testcase: def

  1   2   3   4   >