I found quite strange behavior in Clojure/Cider. When I try to execute the same expression in two ways (to run a test and run in REPL), I have different results.
Here is an expression:
(with-chrome {} driver
(start)
(doto driver
(go "http://localhost:3000")
(wait-visible {:id :domain})
(fill {:id :domain} "foo")
(click {:id :login_button})
(wait 5))
(stop))
The first way is I wrapped it with deftest. The second one I copy and paste it in REPL. The difference is when I run the test the click command does not work at all. While the REPL scenario works as well.
Could somebody give me a tip? PS: I use etaoin library in example above.
Well, the reason was I wrapped he whole code into DB transaction that locked tables due to TRUNCATE operation. That's why clicking on a button sent an ajax request that hanged forever.
Related
I am developing project in clojure using emacs cider under windows. And sometimes I have a problem that after accidently forgotten println function or on printing contents of big file Emacs stops responding (cursor and all key combinations doesn't work) and retire into oneself for processing that information to show it in repl. The only way to continue I know is to close program and open project files from scratch. And it is so simple to get in this trap.
Are there any other better solutions or configuration restrictions?
Though this suggestion will not solve your problem completely, it can help you a little.
First, set *print-length* to some value to limit the number of items of each collection to be printed.
(set! *print-length* 10)
And use cider-connect instead of cider-jack-in. You should run lein repl in a separate console window, then run cider-connect to connect to the repl. Then you can evaluate some expressions in the console window.
It would be good if there's an option to limit the contents to be printed by number of characters, however, I couldn't find it.
I am using Dr Racket for racket programming. I am a newbie.
I have run into this problem where when I type anything on the REPL, lets say:
> (define a 7)
The cursor never returns.
If I define this in the editor
(define a 7)
And in the REPL I do
> a
The cursor never returns.
I do have #lang racket at the very top in the editor window.
It was working just fine for some time and then it suddenly stopped working.
Can you help?
It is an old bug that sometimes appears on Ubuntu, no one has yet figured out why.
On relevant problem report: http://bugs.racket-lang.org/query/?cmd=view&pr=12640
I find it much less frequent these days though.
Meanwhile, I've found that if the pointer doesn't return, you can type other things like 'a or 1.1 followed by Enter, and it should evaluate both expressions at once and return the pointer. Note that the particular case that you give does not occur on my machine.
(define a 7)
should not be printing anything. It is merely binds a to be 7. Try typing a into REPL after and see what you get.
See Racket's documentation on define for further info.
I'm writing a script in Python 2.7 exploring the use of the multithreading and Queue modules. the script just defines two functions, one of which will be started in a thread instance to fill a Queue, and a second one which will be started in a second thread instance to pull something off the Queue. However, I cannot even get this script to execute, as it chokes on one of the function definitions even before it executes. The code snippet with the problem is:
def listenThread(counter):
while queue.empty() != True:
try:
outcome = queue.get()
print outcome
counter -=1
print counter
except:
return 'queue.get() command loop failing.'
The error message I am getting is:
$ python threading-and-queue-test.py
File "threading-and-queue-test.py", line 34
except:
^
IndentationError: unindent does not match any outer indentation level
$
I've searched SO and checked the docs for correct formation of the try-except construct, and it seems OK. I had earlier versions of the code (without the try-except ) working, so I am getting suspicious about the text editor, TextWrangler v4.0.1.
Can anyone suggest a debug approach or code correction?
Thanks!
Red
As you have already suspected, it is most likely an indentation error. Your text editor is probably mixing the use of tabs and spaces. Replace all tabs with spaces (or vice versa though the standard in python is 4 spaces) and you should see the error disappear.
For those who find this question later like I did it's easy to fix TextWrangler's settings and stop this issue altogether; Go to "Preferences" -> "Editor Defaults" -> "Auto-expand tabs" then set tabs to 4 spaces. Restart TextWrangler for changes to take affect. For existing documents that continue giving you a problem read this.
Whenever I evaluate a large value that prints a large datastructure into the repl, slime becomes very slow from then on. Typing anything subsequently into the repl shows a delay in values appearing in the repl and further evaluation of any clojure code is slow. The only thing that seems to work is restarting the repl which doesn't seem like a solution.
An simple example of a large datastructure is slurping a file and then printing it (this could even be a fairly small file).
This seems to happen both in Win7 and Ubuntu.
Any ideas on how to stop this and why it is happening would be appreciated!
When I've run into this issue (which happens often), I simply clear the repl buffer. You can do this with C-c M-o, or by using "Clear Buffer" under the "REPL" menu item. This doesn't restart the repl, and command history and the like are unaffected.
One way you can control how much info is printed from the REPL is from clojure itself using the *print-length* and *print-level* variables.
I installed ClojureBox and the REPL is not working.
If I type (+ 1 2) into the *slime-repl clojure* buffer and press enter, the expression text becomes bold as if it has been evaluated, but there is no result of the evaluation printed on the screen.
Can anyone help me figure out why my REPL is not printing the evaluation results?
Thanks.
Try looking in *inferior-lisp* and failing that all other buffers.
The binding of clojure's *out* plus emacs slime-swank based capture and redirection of output streams can occasionally make it seem like emacs is swallowing output. (This can get really confusing when output comes from multiple threads - definitely one of the few warts of developing clojure with the slime-swank environment.)
Have you ever tried emacs before using clojurebox? Any left behind .emacs configuration or library paths etc. can interact badly with clojurebox which, in my experience, assumes it is the only installation of emacs going onto a clean system.