It appears that AOLserver is not working with packages
that use variables. I think this is the same ongoing
problem that threads don't reinit their variables on reuse.
This precludes writing namespace code that uses package
scoped vars.
Can you please give some more details about your problem?
BTW...
The 4.0 AOLserver is namespace-savvy, i.e. you can
use namespaced code in your Tcl scripts. You can even
make thread blueprint changes from one thread and replicate
this in other threads using ns_eval command.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is a snippet:
namespace eval tools {
variable page_nums ""
variable context_markers ""
variable row ""
variable row_data ""
variable column_count 0
}
is the package init.
in my procs I also add:
variable ::tools::context_markers
variable ::tools::rows
variable ::tools::row_data
variable ::tools::column_count
etc.
This is for a pagination/html table proc.
Depending on which thread I am on (or so it appears), data
is returned correctly (new thread) or appended (same thread)
causing duplicates to be returned from the proc. Once the
thread dies the data is returned normally again.
If you need more information I can attach the whole namespace.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah! Now I understand what you mean.
Unfurtunately, apart from the global namespace, there is
no namespace state cleaning between requests running
on same connection thread. It is a performance issue.
I will have to see if we can do this fast and in generic
way. In the meantime, you can always register a Tcl handler
to be run on connection close and do your own
garbage collection.
I will keep this record but will move this to feature requests
while this is not a bug per-se, strictly speaking.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you give me a quick example of the garbage collection.
I am trying to use the record type in tcllib (not the whole
lib, only the namespace record).
I hope that you can find a way to clear namespace per thread
as many new tcl packages support namespaces, and make heavy
use of variables.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This will instruct the server to perform the above script
at the end of the connection. The command sequence
will reload (=re-source) the package file and thus re-init
the state in current connection thread only. This will not
however cover (i.e. delete) any variables you have created
in the package's namespace.
After some thinking, I'd say that a general Tcl solution to this
issue is pretty costly in terms of speed and would significanlty
impact the server's performance. Perhaps, a C-based Tcl
blueprint snapshot/restore might help, but such thing is not
available in Tcl API until today.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Some people would probably very much like to take advantage
of AOLserver 4.0's Tcl package support even if it might
cause poorer performance. So would it not make sense to
include some sort of configuration option to automatically
re-set package namespace variables to their initial states,
even if the implementation is slow?
Those who take advantage of this feature but find the
performance a problem, can either work around for each
specific package, or contribute to a high-performance
general purpose solution.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The package mechanism works very good in 4.0 series.
The problem appears only when somebody changes the
package state by adding/deleting procs during runtime
(which is bad idea anyways), storing private state information
in package namespace variables and all sorts of such things.
Generally, there is no easy way to get the virgin state of an
package without actually dumping the entire interp and reloading
everything, which is a very time consuming task. You can try this
with:
ns_atclose {ns_markfordelete}
This is of course brute-force but it is unfortunately the only sure
way of getting the virgin interp/package state. All other efforts to
genericallysolve this would have to take many compromises and/or
would therefore be tied to a specific package or usage pattern.
So, I'm just very skeptic that any half-baked solution would meet
peoples expectation. The very proper way and IMHO, the only
practical one is for Tcl people to make a very fast interp blueprint
getter/setter functions which could be called from within the C-code
at connection close.
Maybe we should work towards this instead of trying to get someting
half-way there. AFAIK, efforts have been already made in this direction
but I'm not sure what is the latest status of that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=95086
Can you please give some more details about your problem?
BTW...
The 4.0 AOLserver is namespace-savvy, i.e. you can
use namespaced code in your Tcl scripts. You can even
make thread blueprint changes from one thread and replicate
this in other threads using ns_eval command.
Logged In: YES
user_id=440916
Here is a snippet:
namespace eval tools {
variable page_nums ""
variable context_markers ""
variable row ""
variable row_data ""
variable column_count 0
}
is the package init.
in my procs I also add:
variable ::tools::context_markers
variable ::tools::rows
variable ::tools::row_data
variable ::tools::column_count
etc.
This is for a pagination/html table proc.
Depending on which thread I am on (or so it appears), data
is returned correctly (new thread) or appended (same thread)
causing duplicates to be returned from the proc. Once the
thread dies the data is returned normally again.
If you need more information I can attach the whole namespace.
Logged In: YES
user_id=95086
Ah! Now I understand what you mean.
Unfurtunately, apart from the global namespace, there is
no namespace state cleaning between requests running
on same connection thread. It is a performance issue.
I will have to see if we can do this fast and in generic
way. In the meantime, you can always register a Tcl handler
to be run on connection close and do your own
garbage collection.
I will keep this record but will move this to feature requests
while this is not a bug per-se, strictly speaking.
Logged In: YES
user_id=440916
Can you give me a quick example of the garbage collection.
I am trying to use the record type in tcllib (not the whole
lib, only the namespace record).
I hope that you can find a way to clear namespace per thread
as many new tcl packages support namespaces, and make heavy
use of variables.
Logged In: YES
user_id=95086
While not being an ideal solution, you might want to try
this one:
ns_atclose {
package forget YourPackage
package require YourPackage
}
This will instruct the server to perform the above script
at the end of the connection. The command sequence
will reload (=re-source) the package file and thus re-init
the state in current connection thread only. This will not
however cover (i.e. delete) any variables you have created
in the package's namespace.
After some thinking, I'd say that a general Tcl solution to this
issue is pretty costly in terms of speed and would significanlty
impact the server's performance. Perhaps, a C-based Tcl
blueprint snapshot/restore might help, but such thing is not
available in Tcl API until today.
Logged In: YES
user_id=43168
Some people would probably very much like to take advantage
of AOLserver 4.0's Tcl package support even if it might
cause poorer performance. So would it not make sense to
include some sort of configuration option to automatically
re-set package namespace variables to their initial states,
even if the implementation is slow?
Those who take advantage of this feature but find the
performance a problem, can either work around for each
specific package, or contribute to a high-performance
general purpose solution.
Logged In: YES
user_id=95086
Just to be more precise...
The package mechanism works very good in 4.0 series.
The problem appears only when somebody changes the
package state by adding/deleting procs during runtime
(which is bad idea anyways), storing private state information
in package namespace variables and all sorts of such things.
Generally, there is no easy way to get the virgin state of an
package without actually dumping the entire interp and reloading
everything, which is a very time consuming task. You can try this
with:
ns_atclose {ns_markfordelete}
This is of course brute-force but it is unfortunately the only sure
way of getting the virgin interp/package state. All other efforts to
genericallysolve this would have to take many compromises and/or
would therefore be tied to a specific package or usage pattern.
So, I'm just very skeptic that any half-baked solution would meet
peoples expectation. The very proper way and IMHO, the only
practical one is for Tcl people to make a very fast interp blueprint
getter/setter functions which could be called from within the C-code
at connection close.
Maybe we should work towards this instead of trying to get someting
half-way there. AFAIK, efforts have been already made in this direction
but I'm not sure what is the latest status of that.