Re: Vibe-d issue with timer in separate thread on debug builds
Am 10.01.2018 um 15:40 schrieb Andres Clari: Hi, I have an app that uses vibe tasks, fibers and timers extensively, and I found an issue only for debug builds, when canceling a timer. However the code in question works just fine in the release build. But having this here makes testing certain things in my program a pain, since it'll crash on the assert in question: vibe-d-0.8.2/vibe-d/core/vibe/core/drivers/libevent2.d:474 debug assert(m_ownerThread is () @trusted { return Thread.getThis(); } ()); Also, not sure I understand that assert properly... Is it checking the stop timer call is fired from the main thread the event loop is running? That would be bad, since basically that timer run from a child thread. The basic requirement for almost all vibe.d primitives is that they may only be used within the same thread in which they were created. Anything else requires message passing (e.g. using std.concurrency) to issue the operation in the owner thread. There incidentally is a recent thread on the vibe.d forum on this topic: https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/48663/
Re: need help with vibe.d receive()
Am 10.01.2018 um 15:39 schrieb crimaniak: Hi! I make multi-task event bus, but there is a problem with the task stops. Please see end of file https://github.com/crimaniak/d-vision/blob/master/src/vision/eventbus.d Expected behavior: After sending the StopEvent message in line 244 it is must be detected in listeners (line 147), so all listeners must set exit flag to 'true' and quit immediately. De-facto behavior: StopEvent() message is not detected by the first delegate in line 147 (logger task logs this message by the handler in line 185), so subscribed tasks never exit and test stops on line 248. I tried to play with yield() and sleep(), with 'shared' attributes and so on, but without result. Can you say please what I am doing wrong here? 'dub test' can be used to play with tests. The problem is with the `immutable struct StopEvent {}` declaration and the use of `shared(Unqual!StopEvent)` - `shared(StopEvent)` is actually reduced to just `StopEvent`, which internally is expanded to `immutable(StopEvent)` and `immutable` already implies `shared`. However, `Unqual!StopEvent` actually removes the implicit `immutable` from the type, so that `shared(Unqual!StopEvent)` is really just `shared(StopEvent)` and consequently treated as a different type by `receive`. So, removing the `immutable` from the declaration solved the issue for me, but if possible I'd rather remove the `cast(shared Unqual!EventType)` from `emit`, and pass `shared`/`immutable` events to it from the outside (or plain events with no unshared indirections).
Re: vibed services stop response after several days of work
Am 01.09.2017 um 12:31 schrieb Suliman: On Friday, 1 September 2017 at 08:01:24 UTC, Suliman wrote: I got same problem on Windows Server 2016 and on Linux Debian 8.5. I have few very simple backend based on vibed 0.8.1, compiler dmd 2.075.1. nginx servise is do port forwarding. Nothing more is used. After several days of working I am begining to get "502 Bad Gateway" error. The service is not down, it's continue to working, but on Windows task manager I seen very low memory usage (0.4MB) and on Linux I see next: https://snag.gy/ban3jX.jpg (i am not familiar with Linux and do not sure if process is alive or not because htop do not show it) The code is *very* simple https://github.com/bubnenkoff/dlang.ru Is there any ideas how to diagnostic the problem? I got error https://paste.ofcode.org/exCL5S2vbp6qhYBqj7v6ez Is it's issue with libevent? Does even-loop depend on used OS? The dpaste shown doesn't seem to match the code in the repository. There is a reference to vibe.web.rest and the mysql-native driver, which I couldn't find in the dlang.ru source code. The error is most likely caused by issuing two requests to the MySQL server from two different tasks on the same connection. Usually, mysql-native uses a connection pool to avoid this, but that could have been circumvented by accident.
Re: DUB and LTO?
Am 24.01.2017 um 17:02 schrieb Las: How do I enable LTO in DUB in a sane way? I could add it to dflags, but I only want it on release builds. You can put a "buildTypes" section in your package recipe and override default dflags or lflags there just for the "release" build type. See https://code.dlang.org/package-format?lang=json#build-types
Re: Vibe.d diet template reuse
Am 03.11.2016 um 06:31 schrieb Jot: I would like to create some generic diet templates for different html functionality. Some code in the template will need to be setup/changed for it to function properly. How can I write code that allows for one to express generic statements in the template but access/modify them in another template? Is there a way to pass around a context, including functional code between templates? e.g., I might want to create a d function in a diet template that will be used in generating another template. e.g. (pseudo), block -auto MyFunc(int x) { return 3*x; } include test test.dt: block -for(i; 1..MyFunc(3)) ... having such a feature allows me to generalize my templates quite a bit and reuse them for various html features rather than duplicating the majority of the code but I need a way to pass some unspecified functionality to a template before instantiation. The example above should basically work - the included template is inserted into the outer context and can access any functions or variables declared there. Alternatively, you can also define a function in an included template, which then contains/generates the appropriate dynamic content: --- block include test - auto MyFunc(int x) { return 3*x; } - insertFoo(MyFunc(3)); --- test.dt: --- - function void insertFoo(int n) - for (i; 0 .. n) p foo: #{i} ---
Re: DUB, Platform specifications and dependencies
Am 24.11.2015 um 19:51 schrieb Zardoz: Actually I'm trying to setup dub to not grab a dependency on Windows ( https://github.com/Zardoz89/DEDCPU-16/blob/master/dub.sdl ) : name "dedcpu" authors "Luis Panadero Guardeño" targetType "none" license "BSD 3-clause" description "DCPU-16 tools" subPackage { name "lem1802" description "Visual LEM1802 font editor" targetType "executable" targetName "lem1802" excludedSourceFiles "src/bconv.d" excludedSourceFiles "src/ddis.d" dependency "gtk-d:gtkd" version="~>3.2.0" platform="posix" libs "gtkd" platform="windows" } ... How ever, running dub on Windows (tested on two different machines), ignores platform specification for gtk-d dependency . What I'm doing wrong ? Platform specifications are currently not supported for dependencies due to the way the dependency resolver works. However, it is possible to use platform specific configurations for this purpose: name "dedcpu" authors "Luis Panadero Guardeño" targetType "none" license "BSD 3-clause" description "DCPU-16 tools" subPackage { name "lem1802" description "Visual LEM1802 font editor" targetType "executable" targetName "lem1802" excludedSourceFiles "src/bconv.d" excludedSourceFiles "src/ddis.d" libs "gtkd" platform="windows" configuration "nogtk" { platforms "windows" } configuration "gtk" { platforms "posix" dependency "gtk-d:gtkd" version="~>3.2.0" } }
Re: vibe.d-example illustrating Dynamic Textual Web-Interface
Am 30.11.2015 um 11:08 schrieb Nordlöw: Can somebody please show a enlightening example of, so called, "revamp of the REST interface generator" added to release 0.7.26 at: http://vibed.org/blog/posts/vibe-release-0.7.26 I want to use vibe.d to add a modern dynamic web-interface to my knowledge graph I'm currently developing. More specifically I would like an interface that makes rich use of dynamic HTML. When the user changes the contents of a search/command-line text-field the client logic shall on the fly (after a certain delay) lookup related information with vibe.d-server and present the user with relevant hits or completions in a another part of page (HTML div-block). Does anybody have a similar vibe.d-project to be inspired from, in this regard? This would be more targeted to the web interface generator (vibe.web.web), which is not affected by the changes mentioned above, but the interface is pretty similar. For a very simple example, you can have a look at this: https://github.com/rejectedsoftware/vibe.d/tree/master/examples/web_ajax
Re: goroutines vs vibe.d tasks
Am 01.07.2015 um 20:09 schrieb Mathias Lang: On Tuesday, 30 June 2015 at 15:18:36 UTC, Jack Applegame wrote: Just creating a bunch (10k) of sleeping (for 100 msecs) goroutines/tasks. Compilers go: go version go1.4.2 linux/amd64 vibe.d: DMD64 D Compiler v2.067.1 linux/amd64, vibe.d 0.7.23 Code go: http://pastebin.com/2zBnGBpt vibe.d: http://pastebin.com/JkpwSe47 go version build with go build test.go vibe.d version built with dub build --build=release test.d Results on my machine: go: 168.736462ms (overhead ~ 68ms) vibe.d: 1944ms (overhead ~ 1844ms) Why creating of vibe.d tasks is so slow (more then 10 times)??? In your dub.json, can you use the following: subConfigurations: { vibe-d: libasync }, dependencies: { vibe-d: ~0.7.24-beta.3 }, Turns out it makes it much faster on my machine (371ms vs 1474ms). I guess it could be a good thing to investigate if we can make it the default in 0.7.25. This sounds like the event_del() + event_add() sequence that is done in the libevent driver causes this slowdown. If anyone knows of a faster way to rearm a timer for libevent that would be great. Otherwise I don't really know what to do about this (other than using a different driver). As for libasync, making it the default is maybe still a little too early, but we should definitely think about how to make it more prominent for testing (maybe even still for 0.7.24).
Re: goroutines vs vibe.d tasks
Am 01.07.2015 um 09:55 schrieb Daniel Kozák: On Wed, 01 Jul 2015 03:28:01 + rsw0x anonym...@anonymous.com wrote: how do they compare if you replace the sleep with yield? Same problem still extreamly slow Hm, this is strange. I'll have to find some time to profile this. More or less all that yield() does is to call Fiber.yield() and then once processes pending events.
Re: About @ and UDA
Am 15.04.2015 um 18:59 schrieb ketmar: On Wed, 15 Apr 2015 08:53:05 +, Andrea Fontana wrote: My 2 cents. If I remember correctly, @ prefix in @safe, @trusted, @system, etc was added just to avoid keywords pollution, right? Now UDA uses the same prefix: if some new keywords/properties/attributes will be added to D, the same problem will come back again... Is it a crazy idea to deprecate @ for UDAs in favor of something else like #? In this way @xxx will be a language attribute and #xxx will be a user defined attribute. No pollution, no clashes. Maybe it's not too late to do this change. I think it will be not a big effort to replace uda syntax in existing projects (a deprecation warning will help). or make safe and company context keywords. along with body (oh, how i hate the unabilily to declare body member!) +1 for body I still haven't got the reason though, why safe and friends cannot simply be UDAs defined in object.d that the compiler recognizes. I'd also reserve a bunch of @attributes now to avoid a never ending sequence of breaking changes (such as good anti-keywords to scope, immutable, pure etc.).
Re: Vibe.d json to csv
Am 05.04.2015 um 06:24 schrieb Sebastiaan Koppe: (...) I can probably use zip to get the quotes around the names, to avoid concatenation. But it works fine the way it is. The problem is, the following doesn't: ``` void csvRow(const Json jsonObject) { return values(jsonObject.get!(Json[string])).stdMap!(a =``~a~``).joiner(,); } ``` From the looks of it, the problem is that the concatenation there yields a Json value instead of a string (because concatenation also works for adding elements to a JSON array for example). If all elements are known to be strings, using ``~a.get!string~`` should make it work.
Re: using vibe.d to parse json
Am 26.03.2015 um 02:38 schrieb Laeeth Isharc: On Thursday, 26 March 2015 at 01:04:06 UTC, Jakob Ovrum wrote: On Thursday, 26 March 2015 at 00:41:50 UTC, Laeeth Isharc wrote: Yeah, it is not very intuitive. But it works. Thanks. Next question - how can I correctly deal with inconsiderately chosen JSON field names like 'private' (which conflict in a struct declaration with D language keywords). A hack is to do a search and replace on the JSON before presenting it to vibe.d, but I wondered if there was a better way. Incidentally, vibe doesn't seem to like my replacing private with private_ - whereas privateX works. Laeeth. Use the @name attribute: http://vibed.org/api/vibe.data.serialization/name aha! Thanks. (and to dicebot - I am not sure index-based access works as the problem is in parsing stage, not accessing). If I understood the issue correctly, there is also the possibility to append an underscore to the D field name in case of keyword conflicts: struct S { int private_; // will be represented as private } This predated the @name attribute (and UDAs in general) and today the latter is probably more appropriate.
Re: vibed - blocking file I/O via library?
Am 06.04.2015 um 17:45 schrieb Laeeth Isharc: So a very basic question about using vibed for a REST service. I am serving data using REST to another application. For the time being it is internal so it is not a disaster if the fiber blocks. But I wanted to understand what I should be doing - the small server app calls library code to retrieve data for a selected series from a large data store (several files, each up to 45G). This library code uses the standard C/posix APIs for file I/O so isn't written with asynchronous access in mind What do I need to do to make sure that if the library code to retrieve the data takes a long time to return that the whole vibed event loop does not block? Should I start a worker task on another thread and wait for it to return? Or will vibed start another thread to serve a new incoming connection if I am still waiting for data in the meantime. Thanks. Laeeth, You should start a worker thread for this and then use message passing (vibe.core.concurrency) to wait for the results (or alternatively a TaskCondition). I was thinking about including a generic thread proxy in vibe.d that I've used to encapsulate these details when working with libgit in a vibe.d based application, but didn't get to it so so far. I could post a quick gist on GitHub if you want, but I can't remember right now how good/generic the code actually was.
Re: using vibe.d to parse json
Am 24.03.2015 um 06:36 schrieb Laeeth Isharc: On Tuesday, 24 March 2015 at 04:53:39 UTC, Laeeth Isharc wrote: Hi. struct RawGoogleResults { string version_; string status; string sig; string[string][][string] table; } enum json = {version:0.6,status:ok,sig:717451517,table:{cols:[{id:date,label:Date,type:date,pattern:},{id:query0,label:euro crisis,type:number,pattern:}],rows:[{c:[{v:2004-01-02),f:January 2004},{v:0.0,f:0}]},{c:[{v:2004-02-02),f:February 2004},{v:0.0,f:0}]},{c:[{v:2004-03-02),f:March 2004},{v:0.0,f:0}]},{c:[{v:2004-04-02)... auto table = deserialize!(JsonSerializer, RawGoogleResults)(json); I cannot pass a string to deserialize (the documentation suggests an input range should be fine): http://vibed.org/api/vibe.data.serialization/deserialize I have a feeling maybe deserialize doesn't do what I want, but what should I be using instead. (I would like to parse the json and shove the results in the struct above). Thanks. Laeeth. Okay - figured it out from the source code. auto results = deserialize!(JsonStringSerializer!string, RawGoogleResults)(json); and easier to write: struct RawGoogleResults { string version_; string status; string sig; //Json!array[string][][string] table; Json table; } There is http://vibed.org/api/vibe.data.json/deserializeJson for this specific case. I'll mention that in the documentation of deserialize().
Re: Temple templates with vibe.d support and first D experiences
Am 20.03.2015 um 10:42 schrieb István Zólyomi: Still does not compile, thanks for the idea though. I think it's better to avoid Temple, compilation of Diet templates seems to be better anyway. E.g. temple seems to accept % var.nonexistingname % while diet gives a compile error for #{nonexistingname}. Meanwhile I figured out an easy way to use existing HTML files with Diet, you can avoid reformatting your files to this exotic format. Just mark each line to be predefined content, simply prefixing them with the '|' character like this: doctype html | html | head title testing vibe /title /head | body | h1 My vibe example /h1 | Hello #{username}! | p #{content} /p | /body | /html This can be easily automated by a few-liner script or whatever you prefer. On Wednesday, 18 March 2015 at 16:27:41 UTC, John Colvin wrote: It might not solve your problem but i strongly recommend using 2.066.1 instead. There are serious problems with 2.066.0 that were fixed in 2.066.1 Another possibility is to use a Jade-to-HTML converter, such as http://html2jade.org/
Re: feature request for dlang.org library preview
Am 26.03.2015 um 21:36 schrieb Steven Schveighoffer: So I just noticed, when I click on source code button for a function in dlang.org library preview, it brings me to the source code as of that release, but to the file itself (on github). I'd like it to go to the specific line where that function is defined instead. I'm not sure if we need updated output from dmd, or if this is all ddox, so I don't know where to file this feature request. Does one file ddox requests on issues.dlang.org? -Steve This had actually already been implemented, but obviously got broken at some point. I'll look into that. As for bug reports, there are some of them on issues.dlang.org, but the more direct way would be to file them at the ddox repository on github (even if this particular issue is really specific to dlang.org).
Re: DUB Errors
Am 05.10.2014 15:50, schrieb Nordlöw: On Sunday, 5 October 2014 at 06:39:00 UTC, Sönke Ludwig wrote: Judging by the log output it should be fixed (on vibe.d's side) with [1] by using a version based dependency to the OpenSSL bindings with an old version*. I've tagged a new RC-2 version now (although it's not really an RC with more known fixes to come). * Since there was no reaction on the corresponding ticket [2], I've decided to tag my own fork instead and register it on code.dlang.org. If anyone has a better idea... [1]: https://github.com/rejectedsoftware/vibe.d/commit/4fd45376a81423adae33092326b5be2cc69422c8 [2]: https://github.com/D-Programming-Deimos/openssl/issues/17 Is reset my dub.selections.json and now things work. Thx. Oh right, didn't think about that, sorry. BTW, `dub upgrade` would be an alternative to deleting the dub.selections.json file.
Re: DUB Errors
Am 05.10.2014 02:11, schrieb David Nadlinger: On Friday, 3 October 2014 at 23:00:53 UTC, Brian Hechinger wrote: With my old set of packages I had no problems. I just now deleted ~/.dub and now I too get this error. Some issue with the openssl module, yes, but what? This is a bit of an issue. :) At first glance, this seems like a forward reference issue. deimos.openssl.ossl_typ imports deimos.openssl.ssl, but also the other way round. I had a similar problem where everything worked before, but then I deleted all DUB caches and now vibe.d doesn't build anymore (master and 0.7.21-rc1). David Judging by the log output it should be fixed (on vibe.d's side) with [1] by using a version based dependency to the OpenSSL bindings with an old version*. I've tagged a new RC-2 version now (although it's not really an RC with more known fixes to come). * Since there was no reaction on the corresponding ticket [2], I've decided to tag my own fork instead and register it on code.dlang.org. If anyone has a better idea... [1]: https://github.com/rejectedsoftware/vibe.d/commit/4fd45376a81423adae33092326b5be2cc69422c8 [2]: https://github.com/D-Programming-Deimos/openssl/issues/17
Re: DUB git master hang
Am 15.07.2014 00:29, schrieb Nordlöw: On Monday, 14 July 2014 at 22:27:48 UTC, Nordlöw wrote: and then it hangs with same behaviour. It finally got through...hmm maybe I'm on a slow 3g-network currently... Although the log indicates that it hung while extracting the downloaded zip file. It's a bit strange because nothing has changed in the relevant section of code for a while and all it does is iterate twice over the files included in the zip file and to extract them in the second iteration. Maybe some kind of Phobos regression? Which DMD version do you use? BTW. the DUB forums are usually much better in terms of responsiveness, because I rarely get the time to read here: http://forum.rejectedsoftware.com/groups/rejectedsoftware.dub/